Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBS - System Restore (XP SP2 VBS Script)

    Hi folks,

    I am trying to adapt a script from the Technet Scripting centre that performs a System Restore on a remote machine (XP SP2) and then forces a system reboot. Whilst the script runs correctly, the PC is hanging on the forced system reboot and has to be cold booted to get it back up again. On re-boot, a System Restore entry does appears in the System Restore GUI, but it is not being applied correctly (i.e. carried out to completion) - an event log entry indicates that the System Restore operation was interrupted (probably when we cold boot the PC). NB: We have the PC on for at least 30 minutes before cold booting it.

    This MSDN article states that the "The caller must force a system reboot. The actual restoration occurs during the reboot". So, using the parameters stated in this MSDN article, we have the appropriate code in our script to force the PC to reboot.

    Therfore, I end up with this script (its a bit messy)...

    +++++++++++++++++++++++++++++++++++
    'Conducts a System Restore on Windows XP and then forces reboot of PC

    'Get input from user

    Restore_Point = InputBox ("Please enter the restore point you wish to use...")
    strComputer = InputBox ("Please enter the NetBIOS computer name, or IP, of the PC against which you want to run this script...")

    'Perform System Restore

    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "rootdefault")
    Set objItem = objWMIService.Get("SystemRestore")
    errResults = objItem.Restore(RESTORE_POINT)
    Set objWMIService = Nothing
    Set objItem = Nothing

    'Initiate FORCED reboot of PC

    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!" & strComputer & "rootcimv2")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Shutdown(6)
    Next
    Set objWMIService = Nothing
    Set colOperatingSystems = Nothing

    'Return message to user

    Wscript.Echo "System Restore on " & strComputer & " started. " & strComputer & " will now reboot."

    Set strComputer = Nothing
    +++++++++++++++++++++++++++++++++++

    NB: We enumerate the restore point to use via another script, which is working OK.
    Permissions aren't an issue against the remote machine. The script is run by Domain Admins, who have the appropriate local rights to perform a system restore.

    Does anyone have any ideas as to why this isn't working correctly (either the System Restore or the forced reboot that is required)?

    TIA,

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBS - System Restore (XP SP2 VBS Script)

    Could you be running into hardware issues on the remote machine? My old laptop ran Windows NT just fine, but when I upgraded to XP, it would hang on restart every time, so I had the same problem with system restore on that machine that you are describing. Find out if the user of that machine can successfully create a system restore point at the machine.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS - System Restore (XP SP2 VBS Script)

    Thanks for that Charlotte.

    It does look like a hardware issue (related to the force reboot code). We have progressed a little further now...

    If we just run the System Restore code against the remote machine (whilst at Ctrl Alt Delete screen), and then get the user to re-boot the local PC via the shutdown button on the logon screen; the machine shuts down and the "Performing System Restore" gui appears. The System Restore completes OK, the machine reboots and the a successful System Restore event is logged.

    So, it does look like a hardware issue with the force reboot code, doesn't it? At least we're partly automating the process...

    All I have to do now is get the System Restore code to run against the machine when it is booted to "Safe Mode with Networking" (not working at present). This is our driver for this script - we have a hardware issue where we can only boot some PC's to Safe Mode with Networking; performing a System Restore gets them going again...and we need to be able to do it over our WAN.

    I assume the System Restore script is not working in Safe Mode as the WMI classes may not be loaded?

    Any pointers out there please?

    Cheers,

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS - System Restore (XP SP2 VBS Script)

    Quick update and closure of this thread...

    Have given up trying to script the System Restore and reboot/shutdown together. Have opted for manual reboot by user, or remote client, after System Restore has been set. Am assuming that it's our hardware that is not responding properly to the reboot/shutdown script.

    Therefore, we have ended up with two scripts. One to enumerate the System Restore Points available and the other to perform the actual System Restore (both are below). We needed these to run against remote PC's that were in safe mode. To do this, we had to enable the "Allow Remote Administration" exception in the Windows XP SP2 non-domain settings firewall (risky, but had to be done). We did this via Group Policy.

    Here are the two scripts...

    Long code fragment (over 3,000 characters) moved to attachment by HansV

    Thanks to those of you who responded on this thread.

    Cheers,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •