We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Shutdown using a .BAT file?

steroyle
steroyle asked
on
Medium Priority
211,399 Views
Last Modified: 2011-08-18
Is it possible to create a bat file that when run, will shutdown or restart your computer. If so where would I find information on doing this?
Comment
Watch Question

IT Project Manager
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
thats a lot of info and kinda confusing to me. Do I just copy and paste the text into a txt file and rename .bat Im not too sure which is code and which isnt. Sorry if im wasting your time but im new to bat files.

Commented:
windows xp already got it:

command line: shutdown                   - shutdown computer
command line: shutdown -r                - reboot computer

On Win9x systems try this:

Create a file in notepad named Shutdown.bat and have this line only in it.

@exit

save and run it. It should shutdown your system.
Again,

You could try this too and it should work as well:

You can use either of the following commands in a batch file to restart Windows 98 automatically:

runonce.exe -q

rundll32.exe shell32.dll,SHExitWindowsEx n

where n is one, or a combination of, the following numbers:

0 - LOGOFF

1 - SHUTDOWN

2 - REBOOT

4 - FORCE

8 - POWEROFF

The above options can be combined into one value to achieve different results. For example, to restart Windows forcefully, without querying any running programs, use the following command line:

rundll32.exe shell32.dll,SHExitWindowsEx 6

NOTE: Using the FORCE option can cause programs to lose data.


this is somewhat udosoft  suggested too, but its lost in all the other technical information :)

But i got it from here :

http://www.geocities.com/~budallen/batfiles.html#Exit%20Windows%2098%20Automatically%20Using%20a%20Batch

Commented:
steroyle, instead of just complaining about it bieng confusing, TELL US what is your OS!!! then we can just give you the code that applies to your particular case. until then, we can't answer to your question in a less confusing manner.

Author

Commented:
georgir dont cry, like i said im sorry if im wasting anyones time. I dont spend my life reading these forums!

Thanks udosoft it worked a treat!
I want to write a program in c++ that it can shutdown computer .
HELP ME

Commented:
Just use rundll32.exe shell32.dll,SHExitWindowsEx 8

Commented:
in a batch file on winxp you can do this with more options!!!!

Such as
remote shutdown - shutdown computers on the network - graphical interface - shutdown /i
timed shutdown   - shutdown /t xx seconds
full list is available in win xp and 2000 by opening cmd and putting in shutdown /?
here is the easy way:

1. Create a shortcut to C:\WINDOWS\SYSTEM32\SHUTDOWN.EXE
2. Right click the shortcut, then click properties.
3. Add -s to the end of the text in the 'target:' textbox
4. Click ok
5. Run it and the countdown should begin.

you can easily execute this with your application... Look up more on this about how to get rid of the countdown
 
I want to use shutdown.exe (or something else) to shutdown a remote w3k server from a batch file, but I do not want the batch file to return (keep running) till the remote machine has compleated its shutdown.  Once the shutdown has finished, the batch file cna continue to run.

Any sugestions?

Commented:
Please post a new question.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.