Monday, February 18, 2008

Shut Down, Damn You!

You're in a hurry (let's say, you're about to miss a flight), so you order your machine to shut down, close the laptop's screen, shove it in your backpack and rush out of the office. You pull it out later, only to find out the machine didn't shut down, because it has been waiting for some frickin' process to end. On the screen is that useless "would you like to end this process?" dialog (no, I don't really want to end it - I just clicked "Shutdown" out of boredom mad).

And so, yesterday I sat down in the plane, pulled out my laptop, only to find out it's burning hot (being cooped up in the backpack) and that two-thirds of the battery are gone.

Well, enough is enough! After some research, here are 2 easy ways to solve this annoying problem:

1. The bypass (beginner level)
  1. Type the following into a text file: shutdown -t -s 00
  2. Save the text file with a .bat or .cmd extension (doesn't really matter) - this will turn the text file into a batch file.
  3. Put the file anywhere you want. Change its icon if you feel like it.
  4. Add a shortcut to the batch file to your Quick Launch bar.
  5. Click that shortcut whenever you want Windows to shutdown
    - be careful not to hit it by mistake! No second chances here.
2. The registry hack (expert level)
  1. Open the registry editor (click Start->Run and type regedit).
  2. Locate the registry Key: HKEY_USERS\.DEFAULT\Control Panel\Desktop.
  3. Locate the value AutoEndTasks.
    If it doesn't exist - create it (type of String Value - REG_SZ).
  4. Change/add the value data to 1 (the default is 0).
  5. Close regedit and reboot.
I chose the second method - you can always revert back to the default value, should you need it. And no chance of shutting down by mistake.

PS: by the way, just in case you think things are better on the Mac: my Mac usually hangs the shutdown process, whenever any other application is still running. The most common situation is when Firefox was running when I chose to shutdown, the machine will wait for the "Do you want to save the tabs?" dialog.
I Will look for a hack on Mac OS and publish it here when/if I find it.

11 comments:

Anonymous said...

Hibernation is not only for bears , you know.


(I know you know. I wonder why you are not using it)

Traveling Tech Guy said...

Actually, 9 out of 10 times, I am using hibernation. Faster and keeps me in context.

But the one time I want a true restart (like when I installed another bunch of MS updates), or when my memory has been corrupted enough (after a month of hibernations), I couldn't get the bugger to shut down.

Well now I can :)

Kenyan Diaspora Pro-democracy Movement said...

Nice Blog!

Anonymous said...

Hibernation seems to be quite slow on my system, and might not work with Linux. Suspend-to-RAM works great in both OSes, is fast, and uses very little batery power.

Anonymous said...

A down side to hibernation is drive space required.

Will said...

Found via stumbleupon, and I think I can answer your Mac problem. Paste this into the AppleScript Editor (/Applications/AppleScript/Script Editor):

do shell script "shutdown -h now" user name "admin_user" password "password" with administrator privileges

replace admin_user with the shortname of an Admin user on your machine, and password with the password for that user. Save as an Application, run only (select "Application" in the dropdown menu and check the run-only checkbox) so nobody else can read your password. On my system, with Firefox, Textedit, iTunes and an active Terminal window, it shut down in a matter of seconds.

Adam Brenecki said...

On Linux and Mac OS, the command is 'shutdown -P now'. I haven't tried it though, so play with it a bit. It should be run with superuser priveliges, to do this either prepend the command with 'sudo' (Debian/Ubuntu) or execute 'su' beforehand (RedHat/Fedora). I'm not sure which one of these Mac OS uses, as I've managed to render my Leopard partition unbootable.

Will said...

@abrenecki
The only valid options in OS X are -h, -k, -r and -s, for halting, kicking all users, restart, and sleep respectively. I haven't used Linux in a while, so -P probably works there, but not on OS X.

Unknown said...

Linux doesnt suffer from this problem

Just shut it down with
shutdown -h now
thats it

Unknown said...

Hmmmm.... I'm not sure using "shutdown -t -s 00" is such a good idea. Why not set the delay time to 15 seconds or so? (shutdown -t -s 15)
This ways, if you hit it by accident, you have 15 seconds to run "shutdown -a" from command prompt to abort the process.

Zaerion said...

i agree with what perry said. also, you could run the command as "shutdown -f -s -t 15". the -f forces any open programs closed (like when word asks you if you want to save changes before closing a file).