Re: Shutdown
From: Torgeir Bakken (MVP) (Torgeir.Bakken-spam_at_hydro.com)
Date: 05/01/03
- Next message: Michael A. Covington: ""You do not have permission to change your password""
- Previous message: Robert Moir: "Re: Second Logon Box"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 01 May 2003 00:10:31 +0200
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
- Next message: Michael A. Covington: ""You do not have permission to change your password""
- Previous message: Robert Moir: "Re: Second Logon Box"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|