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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script will not reboot PC.

Status
Not open for further replies.

SWarrior

MIS
Dec 19, 2003
111
US
While rolling out an install of new AntiVirus, the machine will not reboot when told to by script. The "Post Install" command is as follows:


wscript RemoveNAVKey.vbs //B //Nologo


Inside RemoveNAVKey.vbs, this script removes a registry entry successfully if found. However, I can NOT get this script to reboot the pc. BUT, when the script is run FROM the machine manually, it successfully completes. Do keep in mind that there is no actual user logged onto the PC at the time. The script is run with admin rights. The snip of the code that is supposed to reboot is as follows.

Code:
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

Const EWX_LOGOFF   = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT   = 2
Const EWX_FORCE    = 4
Const EWX_POWEROFF = 8

WScript.Sleep(120000)

Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")

For Each OpSys In OpSysSet
	OpSys.Win32Shutdown EWX_FORCE
Next

Thanks in advance for any tips.
-SWarrior
 
Hello SWarrior,

To be exact, try this?
[tt]
OpSys.Win32Shutdown EWX_FORCE or EWX_REBOOT
[/tt]
regards - tsuji
 
tsuji,

I've actually tried both of those options already. I'm really lost here, espeically when it works if you execute it while logged onto the machine, but not when called from the program's "Post Install" option. But it's only THAT portion of the script that does not run. Grrrrrrrrrrr

-SWarrior
 
All for not, I've even tried this code as well, and it does not work either!! Double Grrrrrrrr

Code:
strRootPath = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
strComputerName = "\\" & ucase(WSHNetwork.ComputerName)

rc=fso.CopyFile("\\WCBackup02\InoRemote$\Image\Shutdown.exe", strRootPath & "\System32\")

WScript.Sleep(10000)

rc=wshshell.run("cmd /c " & strRootPath & "\system32\shutdown -r -f -m """ & strComputerName & """ -t 240",1,True)

Who want's to come and help me beat the crap out of this code ??

-SWarrior
 
we tend to use Shutdown.exe, not sure why, i think its part of the resource kit. saying that ive never tried to run it whilst no one is logged on.

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top