Programmatically reboot XP SP2 via startup script
- From: digital_wasabi@xxxxxxxxxxx
- Date: 20 Apr 2006 04:17:21 -0700
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
.
- Follow-Ups:
- Re: Programmatically reboot XP SP2 via startup script
- From: Ziminski
- Re: Programmatically reboot XP SP2 via startup script
- From: Jerold Schulman
- Re: Programmatically reboot XP SP2 via startup script
- Prev by Date: Need help executing php from vbscript
- Next by Date: Re: How to verify a string is contained in another string???
- Previous by thread: Need help executing php from vbscript
- Next by thread: Re: Programmatically reboot XP SP2 via startup script
- Index(es):
Relevant Pages
|
Loading