Problem with SteadyState script RRS feed

  • Question

  • Howdy all, 

    I'm having a little trouble with a Microsoft SteadyState script I am trying to write. I am Visual-Basic inept, so I'm not surprised I'm having issues. I hope somebody can help me out. 

    Basically, what I'd like to do is be able to set a group of machines to temporarily retain their changes. I have a printer that I need to install through scripting, so I'd like to be able to run a script to "Temporarily retain all changes" for the next 30 minutes, then deploy the script. 

    I originally had the script offered up in multiple forums working. but I have since decided that I wanted to make a few modifications. Namely, I wanted the ability to have it pull the list of computer names from it's Active Directory OU, and then apply the "Temporarily Retain all changes" change to those machines. Then I would have 30 minutes to deploy my installs. 

    At least in my head it makes sense Smile 

    Anyway, the script is not working, as I am getting an Invalid parameter error near the end of the script itself. I'll post the script now so you can see what butchering I've done. Smile 

    Code Snippet

    ' Script to retain changes temporarily for 30 minutes
    ' Define some useful constants 
    ' WDP_Control.CurrentStatus 
    const WDP_ACTIVE  = 0 
    const WDP_PASSIVE = 1 
    ' WDP_Control.CurrentMode 
    const WDP_MODE_DISCARD = 0 
    const WDP_MODE_PERSIST = 1 
    const WDP_MODE_COMMIT  = 2 
    ' Identify the computer to manipulate 
    'Grab computer names from Active Directory OU
    Set colComputers = GetObject("LDAP://OU=Lab 102, OU=EMS Student Computers, OU=EMS Computers, OU=Ebenezer Middle School, OU=Schools, OU=ECSD Domain OU's, DC=ecsd, DC=effingham, DC=k12, DC=ga, DC=us")
    For Each objComputer in colComputers
          strComputer = objComputer.CN
    ' The WDP_Control.PersistDateTime property requires a 
    'FILETIME type.   
    ' The easiest way to create a FILETIME from readable 
    'string is to use 
    ' the WBemScripting.SWbemDateTime object. 
    set dateTime = Createobject ("WBemScripting.SWbemDateTime") 
    ' Set the datetime to 30 minutes from now. 
    dateTime.SetVarDate dateToday+0.0208
    ' Get an instance of the WDP_Control WMI class 
    set objWbemServices = GetObject ("winmgmts:\\" & strComputer & "\root\wmi") 
    set setWdpObjects   = objWbemServices.ExecQuery ("SELECT * FROM WDP_Control")  
      for each objWdp in setWdpObjects 
        objWdp.CurrentMode = WDP_MODE_PERSIST 
        objWdp.PersistDateTime = dateTime.GetFileTime 

    And here is the error I am receiving when I run it from my workstation.

    Windows Script Host Script: H:\tempchange.vbs
    Line: 40
    Char: 5
    Error: Invalid parameter 
    Code: 80041008
    Source: SWbemObjectEx

    The line it is referencing here is :  objWdp.Put_ 

    Any help you can offer is appreciated. Like I said, I am Visual Basic Inept, so I have done a lot of cutting and pasting here and to try and make this work. If you need any extra information, by all means let me know what you need and I'll go digging. 

    Thanks to all who read,


    Wednesday, December 3, 2008 7:44 PM