you can shut down your pc from dos prompt like this :
type .... shutdown -s ( it'll give you 30 secs to save your work and then it'll shutdown)

for restart type shutdown -r
and for logoff type shutdown -l

for more options type shutdown only.

I tested these only on win xp ...

Dani AI

Generated

A short, modern summary and corrections to what you see in the thread: the command-line shutdown facility the OP and described is a supported Windows tool on XP and later — it is the documented way to shut down, restart, set timeouts, send messages and target remote machines. (learn.microsoft.com) If you hit the error reported on a Windows 2000 box, that is expected: Win2000 did not ship the newer shutdown utility by default (it was supplied in the Windows 2000 Resource Kit). (support.microsoft.com)

Practical options that are safer and still lightweight: install the Sysinternals PsShutdown utility (supported and maintained) if you need extra features or a single-file tool that works across newer OS versions; it is a robust alternative to copying binaries between machines. For scripted or remote automation, prefer PowerShell automation (Stop-Computer / Restart-Computer and remoting) rather than brittle rundll tricks — run scripts elevated and make sure the caller has the shut-down privilege. (learn.microsoft.com)

A note on the old rundll/rundll32 ideas mentioned by : those hacks are fragile and unsupported. Rundll32 only safely calls specially written export entry points; using it to invoke ExitWindowsEx or LockWorkStation can corrupt the stack and produce unpredictable results. Use the documented command-line tools instead. If the goal is “switch user” or disconnecting sessions, the supported Terminal Services commands (tsdiscon/tscon) are the right, permissioned way to disconnect or reattach sessions on systems that include them. Test any script on the exact Windows SKU you will run it on and run with proper privileges. (learn.microsoft.com)

Recommended Answers

All 18 Replies

Ahh ... the shutdown -r command ;) I use that command in linux hehe :)

Hey Catweazle I had that in mind too .. but when I tried that .. I clicked on the shortcut ... and bang .... it restarted my pc ... all my work went in vain .. hehe. So I thought I'd better not post that here.

Ahh ... the shutdown -r command ;) I use that command in linux hehe :)

It's been a long time when I used linux but what I remember is that I used to shutdown linux with halt command ... is it still used or shutdown is the new command .... I've used Red Hat Linux 4 I think.

i have tried to use those commands in Win2000 OS but it didnt work it displaied this:
"Cannot find the file “shutdown (or one of its components). Make sure the path and filename are correct and all required libraries are available "

which are those libraries any idea???

To shutdown 2000 from the command lline I think you can use:
rundll.exe user.exe,exitwindows

Well, I know it worked back in Windows 95 anyways.

Is there any shortcut in dos in win98 ???

DOS shutdown commands with fun attachments.

Ok as you know by now when you reach a DOS Prompt you type:

shutdown -s [to shutdown]
shutdown -r [to restart]

Now how about adding a little flavor to them. Especially Windows XP users:

the switches:

-c [allows you to type a comment inside quotation marks that will be shown on screen during the shut down process] ex:

-c "your text here"

-t [this switch allows you to se a time in seconds til the shutdown occurs]ex:

-t 15
-t 84

the first one sets the timer at 15 seconds
the second one sets the timer at 84 seconds
so if you type the following into the command line:

shutdown -r -c "Your computer is now restarting" -t 12


this command creates the following situation:

Restarts the computer:
While displaying a neat dialogue box, with a countdown showing, and showing the message ::: your computer is now restarting :::


There are many other switches as well. Say you don't want to shutdown or restart, you just want to logoff.
type this switch:

logoff.exe

and you logoff.
I'm am still searching for the switch for Switch User though :(

Hope you like this information. It also works inside of batch files as well.
:)

PS: Most all DOS commands work in EVERY DOS invironment. There are very few changes. But yes these commands for the most part also work in 98SE.

On another point. There are many that were not built into the 95 or earlier editions of windows though.

For a fairly complete list of common DOS switches in XP:

Open your CMD/DOS/Command Prompt and type the switch

/?

This is also helpful for finding alternate uses for specific switches: like say you need help with the delete command switch.
type:

delete /?

this will list all of the optional switch addons available for the delete command.

Lightninghawk, that's WAY cool! I'm gonna try that and the one that Catweasle mentioned, too. Maybe the best of both ideas would be a Desktop shortcut to a DOS batch program run full screen....hmmmmm.

Actually.. I have a folder on my desktop that has files that I use to shutdown, restart, and logoff.. I am still looking for the switch in DOS for the Switch User command...

still looking....
google is my friend but it's not being cooperative......

if anybody else finds that command please post here :)

I saw this thread today and i thought id make a console program in c++ using :
system("shutdown -s")

It works quite well and is alot easier cus of the .exe file

also ive been looking for a way to switch user but no luck so far.
whats the point though when you can just use windows logo + L

Hm, good idea, but wouldnt it have been easier to make a bath file (.bat)? Or just make a shortcut...


-T

Owel it wasnt to hard

and neway i dont no how to make a "Bath file" or what it does???

Hi a batch file is a file used to execute commands. To use a batch file open up a text documents and put

shutdown -s

Then save it as shutdown.bat, when you want to shutdown double click it. More can be read here.

http://www.experts-exchange.com/Miscellaneous/Q_21257745.html

-T

ow k cheers i get it now

neway now my program includes a varible for how long til shutdown\restart and all the options in 1 .exe could you do that in a batch file?

Yes, that link i sent you shows it, just add that to the batch file, this could also be done via command prompt.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.