Shortcut

  • Thread starter Thread starter Tim Gay
  • Start date Start date
Tim said:
Does anyone know how to create a shortcut to ShutDown???

Hi

You need to use an external (one that not comes as part of the OS) exe to do
this, or you can use a VBScript that uses WMI for this:


PsShutdown.exe in the PsTools suite ( -k switch)
http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

Wizmo
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 also, put the following code into a file
called e.g. shutdwn.vbs, run it with wscript.exe <path-to-vbs-file>:


' Use "PowerOff" for a poweroff
' Use "PowerOff_Force" for a forced poweroff
' Use "Shutdown" for a shutdown
' Use "Shutdown_Force" for a forced shutdown
' Use "Reboot" for a reboot
' Use "Reboot_Force" for a forced reboot
' Use "LogOff" for a logoff
' Use "LogOff_Force" for a forced logoff

' use "." for local computer

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
 
Please explain how to use PsTools. Thank you. I've already
downloaded the entire suite. Where is the "command-line"?
 
Back
Top