Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript to shudown computer but still run shutdown scripts

Status
Not open for further replies.

cartydave

IS-IT--Management
Oct 9, 2009
2
US
I am familiar with using the shutdown -m command and the WMI method of shutting down a remote computer. The problem with both of these is that neither allow shutdown scripts to run. Does anyone know of a method to shutdown a remote computer while allowing shutdown scripts to run?
 
Is your shutdown script ran via Group Policy? I've never used shutdown scripts, but I do use startup and login scripts via GPO and that works fine.
 
You may have to explicitly call them before issuing a shutdown -m.
Use PSexec.exe to run local commands on a remote computer.

-Geates


 
Use win32_operatingsystem win32shutdown method with parameter 1 (normal, but not forced version):
If you do not get the meaning of the note there on SE_SHUTDOWN_NAME privilege, this sample may give you the form needed despite using a slightly different method.
"How do I" entry:
"...reboot or shut down a remote computer?
 
Thanks tsuji

But that's what I'm currently doing, but shutdown scripts don't run.

set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "")
set colOS = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ShutdownErrCode = ObjOperatingSystem.Win32Shutdown(1)
 
The "for each" loop should end with "next" keyword. Is it there?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top