PDA

View Full Version : Shutdown


Tan Fang Wai
December 5th 03, 07:48 PM
I am using WinXP Pro. I try to shutdown the computer using shutdown.exe. I
then realised that i need to be there to power off the computer. It said, it
is safe to shut down the computer. Anyone know why?

--
In My Prayer,
Tan Fang Wai

"God loved the world so much that he gave his one and only Son. Anyone who
believes in him will not die but will have eternal life."
John 3:16 (NIrV

Torgeir Bakken (MVP)
December 5th 03, 07:48 PM
Tan Fang Wai wrote:

> I am using WinXP Pro. I try to shutdown the computer using shutdown.exe. I
> then realised that i need to be there to power off the computer. It said, it
> is safe to shut down the computer. Anyone know why?

Hi

One downside sometimes with the shutdown.exe that comes with WinXP,
on a lot of computers you end up with "It is now safe to turn off your
computer" and you will need to use the power button to power off...

To avoid that you can use one of the free utilities listed below instead of
shutdown.exe:

Budja
http://www.budja.com/shutdown/

PsShutdown.exe in the PsTools suite
http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

Wizmo.exe
http://grc.com/wizmo/wizmo.htm

Search for
poweroff at http://download.com.com/

Poweroff 3.0 is one of the possibilities.


Using VBScript/WMI works very well, put the following code into a file called
e.g. shutdwn.vbs, run it with wscript.exe <path-to-vbs-file>:


' sleep 30 minutes (time in millisec)
Wscript.Sleep 1800000

' use "." for local computer
' Use "PowerOff_Force" for a forced poweroff
ShutDown ".", "PowerOff"


Sub ShutDown(sNode, sAction)

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

Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" _
& sNode & "\root\cimv2")

Set colOperatingSystems = oWMI.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each obj in colOperatingSystems
Set oOS = obj : Exit For
Next

sAction = LCase(sAction)

Select Case sAction
Case "logoff"
iCmd = EWX_LOGOFF
Case "logoff_force"
iCmd = EWX_LOGOFF + EWX_FORCE
Case "shutdown"
iCmd = EWX_SHUTDOWN
Case "shutdown_force"
iCmd = EWX_SHUTDOWN + EWX_FORCE
Case "reboot"
iCmd = EWX_REBOOT
Case "reboot_force"
iCmd = EWX_REBOOT + EWX_FORCE
Case "poweroff"
iCmd = EWX_POWEROFF
Case "poweroff_force"
iCmd = EWX_POWEROFF + EWX_FORCE
Case Else
' Default value
iCmd = EWX_POWEROFF
End Select

oOS.Win32shutdown iCmd
End Sub



--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter

Google