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


Shutdown using a .BAT file?

steroyle asked
Medium Priority
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?
Watch Question

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


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.

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.


save and run it. It should shutdown your system.

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:






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 :


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.


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 .

Just use rundll32.exe shell32.dll,SHExitWindowsEx 8

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?

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.


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.