Shutdown instead of restart.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I am using a vb script to shut down my XP professional. I posted a copy
below if it makes a difference. The shutdown event is a 2 (ShutdownEvent =
2) which is a restart. We have about 4 or 5 different models of PC’s
strung out over 285 locations. The script basically works day end and day
out except for this one instance. On IBM 300PL’s seemingly random (or
least I have not found a pattern yet) instead of restarting it will
shutdown. The operator comes in at 6:00am and the screen is black and they
press the power button and it starts up. I have a logoff bat and the last
line is an echo to a log. Then I have a startup and it echo to a log. It
is a perfect shutdown a restart as both echoes is in the log. The other
werid thing is not all PL’s do this, but when one “gets in the mood” it
may mess up 3 days in a row (they restart every day) then go 3 or 4 days
without messing up.
Any thoughts?
Thanks
P.E.


Function PerformShutdownEvent()
PerformShutdownEvent = 0 'Assume success

On Error Resume Next

If Delay <> 0 Then WScript.Sleep Delay*1000

Set OpSysSet =
GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}//"+ComputerName+"/root/cimv2").ExecQuery("SELECT
* FROM Win32_OperatingSystem WHERE Primary = true")
If Err.Number Then
OutputLog Error,"Error creating shutdown object. WMI may not be
installed on this machine." & vbCrLf & Err.Source & "(" & Err.Number & "):
" & Err.Description
PerformShutdownEvent = 1
Exit Function
End If

For Each OpSys in OpSysSet
OpSys.Win32Shutdown(ShutdownEvent)
If Err.Number Then
OutputLog Error,"Error executing " & ShutdownDesc & " event." &
vbCrLf & Err.Source & "(" & Err.Number & "): " & Err.Description
PerformShutdownEvent = 1
Exit Function
End If
Next

End Function
'*************************************************************


Quantcast