Programmatically reboot XP SP2 via startup script



Hi,

I require the ability to perform a once-off reboot of multiple XP SP2
machines from a startup script (VBScript applied via Active Directory
Group Policy). The reboot has to occur before the Ctrl-Alt-Del dialog
appears, hence the need to perform it during a startup script.

I have tried using shutdown.exe supplied with the OS, however nothing
happened or was entered in the Event Log, which after investigation
(launching a command prompt from the startup script and running the
shutdown command in the command window) the error output was 'The
device is not ready.' As far as I can tell, shutdown.exe is not
effective at this point in the startup (something to do with
userinit.exe?).

Furthermore, I tried using WMI commands, Reboot & ShutdownWin32, but
they don't seem to work from a startup script either.

Each of the above does work once you have logged on or run as a
Scheduled Task under SYSTEM credentials (after the entire OS has
loaded), but not during the startup script phase which is when it is
needed.

The only thing that did work during the startup script phase was a call
to (SYSInternals) psshutdown.exe but that means deploying to all
workstations, which is logistically and monetarily taxing.

Are there any other solutions?

Here are samples of the Reboot and ShutdownWin32 (using 6 for a forced
reboot) functions I used, perhaps I used the wrong commands/options?
NOTE: LogError is another function that writes an Error Event to the
Event log. This has no problem working during a startup script, and is
therefore irrelevant.

---------------------------------

Function RebootWin32()
Dim oWMIquery
Dim oOperatingSystem

Err.Clear
Set oWMIquery =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!/root/cimv2").InstancesOf("Win32_OperatingSystem")
If Err.Number <> 0 Then
LogError("Could not access WMI database.")
Else
Err.Clear
For Each oOperatingSystem in oWMIquery
oOperatingSystem.Reboot()
Next
Set oOperatingSystem = Nothing
End If
Set oWMIquery = Nothing
End Function

---------------------------------

Function ShutdownWin32(iOption)
Dim oWMIquery
Dim oOperatingSystem

Err.Clear
Set oWMIquery =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!/root/cimv2").InstancesOf("Win32_OperatingSystem")
If Err.Number <> 0 Then
LogError("Could not access WMI database.")
Else
Err.Clear
For Each oOperatingSystem in oWMIquery
oOperatingSystem.Win32Shutdown(iOption)
Next
Set oOperatingSystem = Nothing
End If
Set oWMIquery = Nothing
End Function

--------------

Thanks.

--
Danny

.



Relevant Pages

  • Re: Programmatically reboot XP SP2 via startup script
    ... I require the ability to perform a once-off reboot of multiple XP SP2 ... machines from a startup script (VBScript applied via Active Directory ... For Each oOperatingSystem in oWMIquery ... Set oWMIquery = Nothing ...
    (microsoft.public.scripting.vbscript)
  • Re: Programmatically reboot XP SP2 via startup script
    ... I require the ability to perform a once-off reboot of multiple XP SP2 ... machines from a startup script (VBScript applied via Active Directory ... For Each oOperatingSystem in oWMIquery ... Set oWMIquery = Nothing ...
    (microsoft.public.scripting.vbscript)
  • Re: Autologon a non-admin user
    ... I've discovered the registry settings are being set correctly (via GP ... PC with no autologon settings is rebooted at the same time the autologon ... the startup script is applied but the autologon ... On next reboot, ...
    (microsoft.public.windows.group_policy)
  • Re: Autologon a non-admin user
    ... > startup script), but the autlogon only starts workin on the 2ND reboot. ... PC with no autologon settings is rebooted at the same time the ... On next reboot, ... I suspect that the GPO applies it after the ...
    (microsoft.public.windows.group_policy)

Loading