PDA

View Full Version : Re: Shortcut icon for "SHUTDOWN"


Torgeir Bakken (MVP)
April 14th 03, 09:27 PM
"JEFF B." wrote:

> Is there a way to create a shortcut icon to shutdown my
> computer instead of following the 3 steps needed to get to
> Shutdown in XP? I don't know where the "shutdown.exe" (or
> whatever it may be called) is. Thanks for any info! Jeff

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:

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

PowerOff
http://www.stefan-kuhr.de/poweroff/main.php3

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

nemesis
April 14th 03, 10:01 PM
Right-click on the Desktop and choose New | Shortcut from
the pop-up menu and paste this into the box %windir%
\System32\shutdown.exe -s -t 00
click next now name the shortcut Shutdown and then click
finished now right click on the new shortcut and then gogo
properties click on the change icon and select the
shutdown icon from shell32.dll
>-----Original Message-----
>"JEFF B." wrote:
>
>> Is there a way to create a shortcut icon to shutdown my
>> computer instead of following the 3 steps needed to get
to
>> Shutdown in XP? I don't know where the "shutdown.exe"
(or
>> whatever it may be called) is. Thanks for any info! Jeff
>
>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:
>
>PsShutdown.exe in the PsTools suite
>http://www.sysinternals.com/ntw2k/freeware/pstools.shtml
>
>PowerOff
>http://www.stefan-kuhr.de/poweroff/main.php3
>
>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