Re: Shutdown

From: Torgeir Bakken (MVP) (Torgeir.Bakken-spam_at_hydro.com)
Date: 05/01/03


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


Relevant Pages

  • Re: Wind Power
    ... >> I don't see any option as being proven safe and safe is how I would ... > Is coal safe as a fuel source? ... > solution of no power at all). ... Emanuel Burton, who knew that ...
    (sci.energy)
  • Re: Alaska PFD
    ... Are you saying we should compare nuclear ... power - which powers 70% of France, a good portion of the United States ... if it's clean and safe then that's really a non-issue. ... tons of chemicals that could also be very deadly to you. ...
    (alt.vacation.las-vegas)
  • Re: Olwyn Mary in New Orleans
    ... Glad to hear she is safe and sound. ... She did say that there is about a foot of water ... Of course, with no power, that will only last for so long!! ... > sewing group. ...
    (alt.sewing)
  • Re: Alaska PFD
    ... Are you saying we should compare nuclear ... power - which powers 70% of France, a good portion of the United States ... if it's clean and safe then that's really a non-issue. ... tons of chemicals that could also be very deadly to you. ...
    (alt.vacation.las-vegas)
  • Re: Powerup After Power Failure - PE 1650?
    ... connected to power. ... PE1650 running fedora & poweroff ... but 'ipmitool -I open chassis policy always-on' returns "Power Restore ...
    (comp.os.linux.hardware)