This one’s a bit more esoteric. Have you ever been using Remote Desktop to access a Windows machine and noticed that there is no ‘Shut Down’ button on the Start menu? What if you needed to restart the machine remotely? What if a co-worker was pissing you off, and you wanted to give him what-for?
Enter one of my favorite commands, largely unheard of, but fun for the whole family: ’shutdown’.
It isn’t a complicated command. On your own machine, bring up the ‘Run’ box by clicking ‘Start’, then ‘Run’ (this works in Windows 2000 as well as XP, whether or not Remote Desktop is active on that machine). In the box type ‘cmd’. A command window will pop up.
Now type ’shutdown /?’, just for fun. The following should come up:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
       No args                Display this message (same as -?)
       -i                     Display GUI interface, must be the first option
       -l                     Log off (cannot be used with -m option)
       -s                     Shutdown the computer
       -r                     Shutdown and restart the computer
       -a                     Abort a system shutdown
       -m \\computername      Remote computer to shutdown/restart/abort
       -t xx                  Set timeout for shutdown to xx seconds
       -c “comment”           Shutdown comment (maximum of 127 characters)
       -f                     Forces running applications to close without warning
       -d [u][p]:xx:yy        The reason code for the shutdown
                               u is the user code
                               p is a planned shutdown code
                               xx is the major reason code (positive integer less than 256)
                               yy is the minor reason code (positive integer less than 65536)
Yeah, it’s a little confusing. But there is really only one command combination we need from this to reboot a remote machine, and it looks like this:
shutdown -r -f -m \\computername
Let’s break it down: ’shutdown’ is the instruction, ’-r’ tells it to reboot, ‘-f’ tells it to force quit any running applications, and ‘-m \\computername’ tells it which computer to do the deed to. Of course, replace the ‘computername’ part with the actual name of the computer being rebooted.
This command is especially useful if the only way you can access a machine is via Remote Desktop (as I do with my file server), and you get the ‘too many sessions’ error, where you aren’t allowed to log into your machine (as I occasionally do).
The next time my wife starts pissing me off while she’s on the computer downstairs…..
Not quite.
Shutting down a different computer on the network requires that you have administrator privileges and (at least) have a duplicate account with the same password on the target computer (I’m not sure if the target computer needs to be logged into that account or not).
Why? We use this both to shut down computers via remote desktop often and embed the command in our code as well where I work. It’s quite useful if you have a piece of hardware with multiple computers inside.
Also, the ‘-t’ flag is quite nice if you set it to ‘-t 0′ - this sets no delay on the active or target OS for shutdown - and if it’s a different OS, then the user would have no warning that anything is about to happen.
Wait, you routinely shut down your file server just to force some RDP sessions to exit? Are you retarded?
I have a new “tech tip” for you. It’s called the Terminal Services Manager — you may want to run that, you know, before you just go ahead and reboot the file server for the umpteenth time…
Couple of things:
While Geoff is correct in saying you need an admin account to use this tool, on a domain, you don’t need to have an account on the machine, as long as you have admin privileges to the domain.
While J correctly indicates that Terminal Services Manager can kick out RDP sessions on another machine, neither 2000 nor XP Professional come with that tool.
OH NOES!!!!!!
We just tried this as a test (I was not 100% sure of my previous statement). My SQA lead was unable to reboot my laptop: “Access Denied”. Probably becuase he did not have administrator privileges on our network.
So, if Russtopher has set up a home network properly, and has admin privileges, he should be able to able to start a nice little domestic squable (you’re a braver man than I if you try this…).
Nonetheless, we do find this command very usefull when we remote desktop connect into computers in one of our products - since the computers in question do not have dedicated keyboards, mice, and monitors, remoting in is the only way to manage them, and using the ’shutdown’ command is the only (safe) way to power down or reboot one of them (short of killing the power - which can sometimes have rather nasty results).
I was half joking…. usually I’ll just knock her off the wireless
Carl,
What’s up man? I am friends with your Allison, through work. You and I have hung out once or twice at my girlfriend’s house for some nonsense parties, and I was there the other week deep in the crowd.
Hey man, I hate to bother you, but I have a computer question or two, and I would love your advice.
Just if you have a second, and don’t mind.
I picked up a machine recently, and it doesn’t have an OS. Can I use boot disks - if I can find any, or do I need an actual Windows disk or two?
What I mean is, can it not boot, if there is nothing there?
I would love to open this sucker up, good. I just need to get in…
All I get is the system bios screen, and then it stops, and reports the bad news “no operating system”
Thanks man, and sorry if this is a stupid quesiton.
I am trying to get back into it.
Thanks,
Jim
Hey Jim,
There are no stupid questions, only stupid answers.
And stupid pedestrians crossing against the light when I am trying to get home.
You need an operating system CD. Bootable is preferable (and almost universal, seeing as ‘boot disks’ like floppies are antiquated and practically obsolete). I don;t know what the specs are for your computer, but you probably need a copy of Windows XP (either Home or Pro, depending on your needs). This can be purchased online, or at your local Staples.
Setting it up is fairly simple once you have this disc. I can walk you through it if you need help.
Shoot me an email at carl AT bostongeek DOT com.