Shutdown instead of restart.
- From: PEnright@xxxxxxxxxx
- Date: Tue, 14 Mar 2006 08:12:24 -0800
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
'*************************************************************
- Follow-Ups:
- Re: Shutdown instead of restart.
- From: Mark L. Ferguson
- Re: Shutdown instead of restart.
- Prev by Date: Missing data in Windows Explorer for mp3's etc.
- Next by Date: Re: Move Outlook to new computer
- Previous by thread: Missing data in Windows Explorer for mp3's etc.
- Next by thread: Re: Shutdown instead of restart.
- Index(es):