• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

How to add code to shut down XP for batch file?

E

Eric

Flightless Bird
I get a batch file, it works fine, but I would like to add code at the end of
file to shut down XP.
Does anyone have any suggestions on how to add code to shut down XP for
batch file?
Thanks in advance for any suggestions
Eric
 
D

dadiOH

Flightless Bird
Eric wrote:
> I get a batch file, it works fine, but I would like to add code at
> the end of file to shut down XP.
> Does anyone have any suggestions on how to add code to shut down XP
> for batch file?
> Thanks in advance for any suggestions
> Eric


C:/WINDOWS\system32\shutdown.exe -s -t 01

--

dadiOH
____________________________

dadiOH's dandies v3.06...
....a help file of info about MP3s, recording from
LP/cassette and tips & tricks on this and that.
Get it at http://mysite.verizon.net/xico
 
J

John Inzer

Flightless Bird
Eric wrote:
> I get a batch file, it works fine, but I would like to add code at
> the end of file to shut down XP.
> Does anyone have any suggestions on how to add code to shut down XP
> for batch file?
> Thanks in advance for any suggestions
> Eric

======================================
I don't know anything about batch files but maybe
the following info will offer something you can use:

shutdown -s -t 0
PATH: %windir%\system32\shutdown.exe -s -t 0

restart -r -t 0
PATH: %windir%\system32\shutdown.exe -r -t 0

Here's how to put an icon on your desktop that'll
shut down your machine quickly:

1. Right-click any empty location on your desktop.

2. Click New, Shortcut.

The Create Shortcut Wizard appears.

3. In the Type the Location of the Item box, type shutdown -s -t 0

--

J. Inzer MS-MVP
Digital Media Experience

Notice
This is not tech support
I am a volunteer

Solutions that work for
me may not work for you

Proceed at your own risk
 
T

The Real Truth MVP

Flightless Bird
shutdown -t 00 the zero's indicated the time in seconds before it starts
the shutdown sequence.

--
The Real Truth http://pcbutts1-therealtruth.blogspot.com/
*WARNING* Do NOT follow any advice given by the people listed below.
They do NOT have the expertise or knowledge to fix your issue. Do not waste
your time.
David H Lipman, Malke, PA Bear, Beauregard T. Shagnasty, Leythos.




"Eric" <Eric@discussions.microsoft.com> wrote in message
news:CF450DF1-3135-4C2A-852C-B9BDFC4CD34E@microsoft.com...
>I get a batch file, it works fine, but I would like to add code at the end
>of
> file to shut down XP.
> Does anyone have any suggestions on how to add code to shut down XP for
> batch file?
> Thanks in advance for any suggestions
> Eric
 
E

EAB1977

Flightless Bird
I have a similar issue. The scheduled task for C:/Windows
\system32\shutdown.exe doesn't appear to work if the computer is
locked by me and I have the "Run if user is logged on" checkbox
checked. Any suggestions?
 
P

Pegasus [MVP]

Flightless Bird
"EAB1977" <koolaid4u@yahoo.com> said this in news item
news:60e4dc80-e269-4ee2-8c16-345c32bd9081@l19g2000yqb.googlegroups.com...
> I have a similar issue. The scheduled task for C:/Windows
> \system32\shutdown.exe doesn't appear to work if the computer is
> locked by me and I have the "Run if user is logged on" checkbox
> checked. Any suggestions?


Have a look at the output from the command

shutdown /?

especially the /f switch. Very informative and essential reading when
writing batch files.
 
T

The Real Truth MVP

Flightless Bird
I don't have an XP box handy right now to try it but here are the command
line switches for the shutdown that you can try.

Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

No args Display help. This is the same as typing /?.
/? Display help. This is the same as not typing any options.
/i Display the graphical user interface (GUI).
This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is
rebooted, restart any registered applications.
/a Abort a system shutdown.
This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning.
Can be used with /d and /f options.
/h Hibernate the local computer.
Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-600, with a default of 30.
Using /t xxx implies the /f option.
/c "comment" Comment on the reason for the restart or shutdown.
Maximum of 512 characters allowed.
/f Force running applications to close without forewarning
users.
/f is automatically set when used in conjunction with /t xxx.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined.
if neither p nor u is specified the restart or shutdown is
unplanned.
xx is the major reason number (positive integer less than
256).
yy is the minor reason number (positive integer less than
65536).

Reasons on this computer:
(E = Expected U = Unexpected P = planned, C = customer defined)
Type Major Minor Title

U 0 0 Other (Unplanned)
E 0 0 Other (Unplanned)
E P 0 0 Other (Planned)
U 0 5 Other Failure: System Unresponsive
E 1 1 Hardware: Maintenance (Unplanned)
E P 1 1 Hardware: Maintenance (Planned)
E 1 2 Hardware: Installation (Unplanned)
E P 1 2 Hardware: Installation (Planned)
P 2 3 Operating System: Upgrade (Planned)
E 2 4 Operating System: Reconfiguration (Unplanned)
E P 2 4 Operating System: Reconfiguration (Planned)
P 2 16 Operating System: Service pack (Planned)
2 17 Operating System: Hot fix (Unplanned)
P 2 17 Operating System: Hot fix (Planned)
2 18 Operating System: Security fix (Unplanned)
P 2 18 Operating System: Security fix (Planned)
E 4 1 Application: Maintenance (Unplanned)
E P 4 1 Application: Maintenance (Planned)
E P 4 2 Application: Installation (Planned)
E 4 5 Application: Unresponsive
E 4 6 Application: Unstable
U 5 15 System Failure: Stop error
E 5 19 Security issue
U 5 19 Security issue
E P 5 19 Security issue
E 5 20 Loss of network connectivity (Unplanned)
U 6 11 Power Failure: Cord Unplugged
U 6 12 Power Failure: Environment
P 7 0 Legacy API shutdown


--
The Real Truth http://pcbutts1-therealtruth.blogspot.com/
*WARNING* Do NOT follow any advice given by the people listed below.
They do NOT have the expertise or knowledge to fix your issue. Do not waste
your time.
David H Lipman, Malke, PA Bear, Beauregard T. Shagnasty, Leythos.




"EAB1977" <koolaid4u@yahoo.com> wrote in message
news:60e4dc80-e269-4ee2-8c16-345c32bd9081@l19g2000yqb.googlegroups.com...
>I have a similar issue. The scheduled task for C:/Windows
> \system32\shutdown.exe doesn't appear to work if the computer is
> locked by me and I have the "Run if user is logged on" checkbox
> checked. Any suggestions?
 
B

Bert Hyman

Flightless Bird
In news:#4Yv#XopKHA.1548@TK2MSFTNGP02.phx.gbl "Pegasus [MVP]"
<news@microsoft.com> wrote:

>
>
> "EAB1977" <koolaid4u@yahoo.com> said this in news item
> news:60e4dc80-e269-4ee2-8c16-345c32bd9081@l19g2000yqb.googlegroups.com.
> ..
>> I have a similar issue. The scheduled task for C:/Windows
>> \system32\shutdown.exe doesn't appear to work if the computer is
>> locked by me and I have the "Run if user is logged on" checkbox
>> checked. Any suggestions?

>
> Have a look at the output from the command
>
> shutdown /?
>
> especially the /f switch. Very informative and essential reading when
> writing batch files.


Using the /f switch is a bad idea if there will be any apps running when
you do the shutdown, since it pulls the rug out from under without
giving them an opportunity to clean up after themselves.

There's also a bug in shutdown that prevents it from working for users
who don't have "Administrator" privileges.

http://blogs.msdn.com/aaron_margosis/archive/2006/01/27/518214.aspx

which involves giving the "SeRemoteShutdownPrivilege" privilege to the
user ID.

--
Bert Hyman St. Paul, MN bert@iphouse.com
 
T

Twayne

Flightless Bird
The phony "MVP" speaks again. Avoid its advice at all costs, including the
good posters it always maligns.


In news:4b6c4006$0$27874$88263eea@blocknews.net,
The Real Truth MVP <trt@void.com> typed:
> shutdown -t 00 the zero's indicated the time in seconds before it
> starts the shutdown sequence.

--
The Real Truth http://pcbutts1-therealtruth.blogspot.com/
*WARNING* Do NOT follow any advice given by the people listed below.
They do NOT have the expertise or knowledge to fix your issue. Do not waste
your time.
David H Lipman, Malke, PA Bear, Beauregard T. Shagnasty, Leythos.


>
>
> "Eric" <Eric@discussions.microsoft.com> wrote in message
> news:CF450DF1-3135-4C2A-852C-B9BDFC4CD34E@microsoft.com...
>> I get a batch file, it works fine, but I would like to add code at
>> the end of
>> file to shut down XP.
>> Does anyone have any suggestions on how to add code to shut down XP
>> for batch file?
>> Thanks in advance for any suggestions
>> Eric




--
--
Life is the only real counselor; wisdom unfiltered
through personal experience does not become a
part of the moral tissue.
 
T

Twayne

Flightless Bird
The Real Truth http://pcbutts1-therealtruth.blogspot.com/
*WARNING* Do NOT follow any advice given by the people listed below.
They do NOT have the expertise or knowledge to fix your issue. Do not waste
your time.
David H Lipman, Malke, PA Bear, Beauregard T. Shagnasty, Leythos.



In news:4b6c532c$0$2592$88263eea@blocknews.net,
The Real Truth MVP <trt@void.com> typed:
> I don't have an XP box handy right now to try it but here are the
> command line switches for the shutdown that you can try.
>
> Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
> [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
>
> No args Display help. This is the same as typing /?.
> /? Display help. This is the same as not typing any
> options. /i Display the graphical user interface (GUI).
> This must be the first option.
> /l Log off. This cannot be used with /m or /d options.
> /s Shutdown the computer.
> /r Shutdown and restart the computer.
> /g Shutdown and restart the computer. After the system is
> rebooted, restart any registered applications.
> /a Abort a system shutdown.
> This can only be used during the time-out period.
> /p Turn off the local computer with no time-out or warning.
> Can be used with /d and /f options.
> /h Hibernate the local computer.
> Can be used with the /f option.
> /e Document the reason for an unexpected shutdown of a
> computer. /m \\computer Specify the target computer.
> /t xxx Set the time-out period before shutdown to xxx seconds.
> The valid range is 0-600, with a default of 30.
> Using /t xxx implies the /f option.
> /c "comment" Comment on the reason for the restart or shutdown.
> Maximum of 512 characters allowed.
> /f Force running applications to close without forewarning
> users.
> /f is automatically set when used in conjunction with
> /t xxx. /d [p|u:]xx:yy Provide the reason for the restart or
> shutdown. p indicates that the restart or shutdown is
> planned. u indicates that the reason is user defined.
> if neither p nor u is specified the restart or
> shutdown is unplanned.
> xx is the major reason number (positive integer less
> than 256).
> yy is the minor reason number (positive integer less
> than 65536).
>
> Reasons on this computer:
> (E = Expected U = Unexpected P = planned, C = customer defined)
> Type Major Minor Title
>
> U 0 0 Other (Unplanned)
> E 0 0 Other (Unplanned)
> E P 0 0 Other (Planned)
> U 0 5 Other Failure: System Unresponsive
> E 1 1 Hardware: Maintenance (Unplanned)
> E P 1 1 Hardware: Maintenance (Planned)
> E 1 2 Hardware: Installation (Unplanned)
> E P 1 2 Hardware: Installation (Planned)
> P 2 3 Operating System: Upgrade (Planned)
> E 2 4 Operating System: Reconfiguration (Unplanned)
> E P 2 4 Operating System: Reconfiguration (Planned)
> P 2 16 Operating System: Service pack (Planned)
> 2 17 Operating System: Hot fix (Unplanned)
> P 2 17 Operating System: Hot fix (Planned)
> 2 18 Operating System: Security fix (Unplanned)
> P 2 18 Operating System: Security fix (Planned)
> E 4 1 Application: Maintenance (Unplanned)
> E P 4 1 Application: Maintenance (Planned)
> E P 4 2 Application: Installation (Planned)
> E 4 5 Application: Unresponsive
> E 4 6 Application: Unstable
> U 5 15 System Failure: Stop error
> E 5 19 Security issue
> U 5 19 Security issue
> E P 5 19 Security issue
> E 5 20 Loss of network connectivity (Unplanned)
> U 6 11 Power Failure: Cord Unplugged
> U 6 12 Power Failure: Environment
> P 7 0 Legacy API shutdown
>
>
>
> "EAB1977" <koolaid4u@yahoo.com> wrote in message
> news:60e4dc80-e269-4ee2-8c16-345c32bd9081@l19g2000yqb.googlegroups.com...
>> I have a similar issue. The scheduled task for C:/Windows
>> \system32\shutdown.exe doesn't appear to work if the computer is
>> locked by me and I have the "Run if user is logged on" checkbox
>> checked. Any suggestions?




--
--
Life is the only real counselor; wisdom unfiltered
through personal experience does not become a
part of the moral tissue.
 
Top