Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shutdown batch file 3

Status
Not open for further replies.

Hobeau

MIS
Apr 19, 2004
77
US
Hey guys, I'm trying to do a simple batch file on my windows xp service pack 2 boxes so I can schedule a nightly shutdown. It does not want to work. I've checked on a ton of different websites and I'm trying a bunch of different ways of doing it and it just doesn't want to work. Is this another one of Micro$ofts many bugs? My code is:

@echo off
shutdown -s -c "nightly shutdown"

If someone could tell me if I'm doing something wrong I would very much appreciate it.
 
Hi, I've just checked our shutdown batch file, the only real obvious difference is the exit from the batch file in ours...

cd\
shutdown /L /C /Y /R /T:01
exit

Also when we scheduled ours, we had to run it as an admin or it failed to run.

HTH

Mike
 
. You have to be a local Administrator
. You cannot have a blank or empty password
 
stussy,

You have to be using a non-native shutdown.exe utility, as:

. The XP native utility has no /Y /R and /C demands a "Comment"

. The synatx is not right for the native utility for a shutdown.

Natively it would be:
shutdown -s -f -t 1

From Help and Support:


Shutdown
Allows 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[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 [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

 
Heheh nothing gets past bcastner! I'm not sure where our exe came from then, we use it on our POS base units (w2k) to give them a fresh start each night.
 
Oh, and Win2k does not natively have a shutdown facility (other than the one for Terminal Servers, which can be used). They hid the shutdown.exe in the Resource Kit for Win2k, and that solves the mystery:
The native XP shutdown.exe has a slightly different syntax.

If you want to use the Win2k Resource Kit version, it is available for download:
Do yourself a favor and rename it something other than shutdown.exe and place it in %windir%\system32

It has no advantages over the XP native version.
 
Thanks for that info, the progs on Karen Kenworthy's site are excellent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top