none
API to change Disk Protection status and saving changes the first reboot RRS feed

  • Question

  • I have been doing some testing with the API for Disk Protection and it works great for turning Disk Protection on and off.  I will like to enable disk protection and reboot saving the changes from the current session.  After re-enabling disk protection, at log off, I get the box asking if I would like to retain the changes.  Is there a way to script that or set it to always retain changes for the first reboot before re-enabling the protection?  The only alternative I can think of is to add yet another reboot in after making changes and before re-enabling the protection, which I really do not want to do.
    Tuesday, July 3, 2007 9:45 PM

Answers

  • Currently, we do not have a publicly documented script to enable/disalbe WDP.

    By the way, for any script questions, we can go to MSDN Forum for help: http://forums.microsoft.com/msdn/default.aspx?siteid=1

     

    Sincerely,
      Sammy Yu

    Thursday, July 5, 2007 11:13 AM
  •  Jan J. wrote:
     Eric K wrote:
    I have been doing some testing with the API for Disk Protection and it works great for turning Disk Protection on and off.



    Eric,

    I think many people would be much obliged if you would publish the actual code you already have and use now.  This would allow us to develop and test solutions for our own environment and then share them here.  In turn these could help you, etc.

    Please show us some code!   :-)

    TIA.

    Jan J.

     

    Turning it on and off is simple to do.  Below is code that will do it (vbscript).  The bigger issue though is initializing it the first time.  That is something we're all trying to figure out a way of doing.  Erik's original post got me all excited too.  I had hoped that he had found a way to initialize WDP before Microsoft had released anything.  I do find a little comfort in Sammy Yu's posting, "Currently, we do not have a publicly documented script to enable/disalbe WDP."  They don't have a publicly available script, but they have an internal one in the works at least.  So, hopefully soon they'll have something that they can make available.

     

    This code turns WDP off:

    Code Snippet
    strComputer= "."
          
    set objWbemServices = GetObject ("winmgmts:\\" & strComputer & "\root\wmi")
    set setWdpObjects   = objWbemServices.ExecQuery ("SELECT * FROM WDP_Control")

    for each objWdp in setWdpObjects
       objWdp.CurrentMode  = 2
       objWdp.Put_
    next

     

    This code turns it back on.

    Code Snippet

    strComputer= "."
          
    set objWbemServices = GetObject ("winmgmts:\\" & strComputer & "\root\wmi")
    set setWdpObjects   = objWbemServices.ExecQuery ("SELECT * FROM WDP_Control")

    for each objWdp in setWdpObjects
       objWdp.CurrentMode  = 2
       objWdp.Put_
    next

     

    This are handy if you're scripting an update or an install that is going to hit all your SteadyState machines.  Initializing WDP during rollout of SteadyState, that's another problem.

    Tuesday, July 17, 2007 3:04 PM

All replies

  •  Eric K wrote:
    I have been doing some testing with the API for Disk Protection and it works great for turning Disk Protection on and off.


    Eric,

    I think many people would be much obliged if you would publish the actual code you already have and use now.  This would allow us to develop and test solutions for our own environment and then share them here.  In turn these could help you, etc.

    Please show us some code!   :-)

    TIA.

    Jan J.

    Wednesday, July 4, 2007 7:05 AM
  • Currently, we do not have a publicly documented script to enable/disalbe WDP.

    By the way, for any script questions, we can go to MSDN Forum for help: http://forums.microsoft.com/msdn/default.aspx?siteid=1

     

    Sincerely,
      Sammy Yu

    Thursday, July 5, 2007 11:13 AM
  •  Eric K wrote:
    I have been doing some testing with the API for Disk Protection and it works great for turning Disk Protection on and off. I will like to enable disk protection and reboot saving the changes from the current session. After re-enabling disk protection, at log off, I get the box asking if I would like to retain the changes. Is there a way to script that or set it to always retain changes for the first reboot before re-enabling the protection? The only alternative I can think of is to add yet another reboot in after making changes and before re-enabling the protection, which I really do not want to do.


    You can enable/disable the prompt about retaining changes by setting this reg key:

    [HKLM\System\CurrentControlSet\Services\Windows SteadyState\Parameters]
    "DontWarnOnDiscard"=dword:0

    Set this to 0 to be prompted, or 1 to disable the prompts.
    Sunday, July 15, 2007 5:10 PM
  •  Jan J. wrote:
     Eric K wrote:
    I have been doing some testing with the API for Disk Protection and it works great for turning Disk Protection on and off.



    Eric,

    I think many people would be much obliged if you would publish the actual code you already have and use now.  This would allow us to develop and test solutions for our own environment and then share them here.  In turn these could help you, etc.

    Please show us some code!   :-)

    TIA.

    Jan J.

     

    Turning it on and off is simple to do.  Below is code that will do it (vbscript).  The bigger issue though is initializing it the first time.  That is something we're all trying to figure out a way of doing.  Erik's original post got me all excited too.  I had hoped that he had found a way to initialize WDP before Microsoft had released anything.  I do find a little comfort in Sammy Yu's posting, "Currently, we do not have a publicly documented script to enable/disalbe WDP."  They don't have a publicly available script, but they have an internal one in the works at least.  So, hopefully soon they'll have something that they can make available.

     

    This code turns WDP off:

    Code Snippet
    strComputer= "."
          
    set objWbemServices = GetObject ("winmgmts:\\" & strComputer & "\root\wmi")
    set setWdpObjects   = objWbemServices.ExecQuery ("SELECT * FROM WDP_Control")

    for each objWdp in setWdpObjects
       objWdp.CurrentMode  = 2
       objWdp.Put_
    next

     

    This code turns it back on.

    Code Snippet

    strComputer= "."
          
    set objWbemServices = GetObject ("winmgmts:\\" & strComputer & "\root\wmi")
    set setWdpObjects   = objWbemServices.ExecQuery ("SELECT * FROM WDP_Control")

    for each objWdp in setWdpObjects
       objWdp.CurrentMode  = 2
       objWdp.Put_
    next

     

    This are handy if you're scripting an update or an install that is going to hit all your SteadyState machines.  Initializing WDP during rollout of SteadyState, that's another problem.

    Tuesday, July 17, 2007 3:04 PM
  •  

    I have not found a GOOD way to install WDP initially.  We do have it scripted in our environment in a quite embarrasing way...but hey, it works.  Basically we use the sendkeys command in a vbscript to get the install going, then wait until the service shows up, and have the script do a reboot.
    Friday, August 31, 2007 3:29 PM