Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shutdown Command Prompt

4 views
Skip to first unread message

Ryan McKibbin

unread,
Oct 26, 2002, 3:19:32 PM10/26/02
to
Does anyone know how I would make a file so I can double
click on it like an icon and my PC will shut down. Please
help!

Please reply via my email address.

Torgeir Bakken (MVP)

unread,
Oct 26, 2002, 4:17:00 PM10/26/02
to
Darrel Whiteley wrote:

> WindowsXP has a program called SHUTDOWN.EXE which allows you to
> easily create icons to shutdown or restart your computer.

Hi
One downside with SHUTDOWN.EXE, on most computers you end up with "It is now
safe to turn off your computer".

To avoid that use the command line utils listed below instead of shutdown.exe:

Wizmo, command line that works for Win2k and WinXP
http://grc.com/wizmo/wizmo.htm

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

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>:

' 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


Eelco de Smidt

unread,
Oct 26, 2002, 3:51:07 PM10/26/02
to Ryan McKibbin
Hee, you are right, it doesn't work anymore!!
It's an old program, i made it in 1996 and had it working on W95&98 put
probably it won't work on XP.

It's got something to do with privileges, i'll get back on this!

Eelco

Ryan McKibbin wrote:

> I tried it and it doesn't work. Do you know how I can make one.
> ----- Original Message -----
> From: "Eelco de Smidt" <e.de....@hccnet.nl>
> Newsgroups: microsoft.public.windowsxp.customize
> To: "Ryan McKibbin" <fastp...@hotmail.com>
> Sent: Saturday, October 26, 2002 8:34 PM
> Subject: Re: Shutdown Command Prompt
>
> > I made a program that does what you want!
> > Create a shortcut on your desktop to this program.
> > You can also assign a shortcut key to it like (alt cltr X)
> >
> > Eelco

Eelco de Smidt

unread,
Oct 26, 2002, 4:04:49 PM10/26/02
to Ryan McKibbin
Hmm, it won't work!
You can try to run in Win95 compatibility mode but my laptop say's "It safe
to turn of your computer" and it won't power down!
I've got to go now, maybe it will try it later.
Eelco

Darrel Whiteley

unread,
Oct 26, 2002, 3:57:55 PM10/26/02
to
WindowsXP has a program called SHUTDOWN.EXE which allows you to
easily create icons to shutdown or restart your computer.

To create a shutdown shortcut on the desktop:

Right click on an open area of the desktop
Select New / Shortcut
Enter in "shutdown -s -t 00" - no quotes
Press the Next button
For the name, enter in anything you like. I just use shutdown.
Click on the Finish button.

For a reboot, enter "shutdown -r -t 00"
For a logoff, enter "shutdown -l -t 00"


Shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c
"message"] [-d[u][p]:xx:yy]

Parameters

-l - Logs off the current user, this is also the defualt. -m
ComputerName takes precedence.
-s - Shuts down the local computer.
-r - Reboots after shutdown.
-a - Aborts shutdown. Ignores other parameters, except -l and
ComputerName. You can only use -a during the time-out period.
-f - Forces running applications to close.
-m [\\ComputerName] - Specifies the computer that you want to
shut down.
-t xx - Sets the timer for system shutdown in xx seconds. The
default is 20 seconds.
-c "message" - Specifies a message to be displayed in the
Message area of the System Shutdown window. You can use a maximum of 127
characters. You must enclose the message in quotation marks.

Tweak written by or based on information submitted by Michael Sullivan

Copyright © 2001-2002 TweakXP.com

MySoulCafe

unread,
Oct 26, 2002, 6:30:30 PM10/26/02
to
You should be able to make a batch file useing the
shutdown command:
ShutdownAllows you to shut down or restart a local or
remote computer. Used without parameters, shutdown will
logoff the current user.

Syntax
shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t

xx] [-c "message"] [-d[u][p]:xx:yy]

Parameters
-l

Logs off the current user, this is also the defualt. -m
ComputerName takes precedence.
-s

Shuts down the local computer.
-r

Reboots after shutdown.
-a

Aborts shutdown. Ignores other parameters, except -l and
ComputerName. You can only use -a during the time-out
period.
-f

Forces running applications to close.
-m [\\ComputerName]

Specifies the computer that you want to shut down.
-t xx

Sets the timer for system shutdown in xx seconds. The
default is 20 seconds.
-c "message"

Specifies a message to be displayed in the Message area
of the System Shutdown window. You can use a maximum of
127 characters. You must enclose the message in quotation
marks.

-d [u][p]:xx:yy

Lists the reason code for the shutdown. The following
table lists the different values. Value Description
u Indicates a user code.
p Indicates a planned shutdown code.
xx Specifies the major reason code (0-255).
yy Specifies the minor reason code (0-65536).

/?
Displays help at the command prompt.
Remarks
If you indicate a major and minor reason code, you must
first define these reason codes on each computer for
which you plan to use the particular reason. If the
reason codes are not defined on the target computer,
Event Viewer cannot log the correct reason text.
Examples
To shut down \\MyServer in 60 seconds, force running
applications to close, restart the computer after
shutdown, indicate a user code, indicate that the
shutdown is planned, log major reason code 125, and log
minor reason code 1, type:

shutdown -r -f -m \\MyServer -t 60 -d up:125:1

>.
>

0 new messages