When you reboot or shut down your computer, you normally have to save all your open documents and close all running programs, because when the computer restarts, your system will restart in “default mode” (no programs or documents open).
Microsoft added support for “hibernation” in Windows 2000 (and refined it further in XP and Vista). Hibernation mode writes the contents of the system RAM to the hard disk, which means that when you “hibernate” a computer, everything you had open – such as a web browser and email program – remain open when you restart your computer. In other words, if you were to type something in a Notepad window and restart your computer without saving the document, the data will be lost forever if you reboot\shutdown, but will remain on your computer if you hibernate.
The only downside to hibernation is that Windows creates a “hibernation file” (HIBERFILE.SYS) on your system that’s equal in size to the amount of RAM that you have. So if you have 2GB of RAM, Windows needs a 2GB HIBERFILE.SYS file on your system.
It can be annoying having that 2GB HIBERFILE.SYS file hanging out all the time if you’ve installed Windows on a smaller hard drive or partition, especially if you’re like me and only hibernate your system when the electricity goes out and you want to shut down your PC before your UPS runs out of juice.
Thankfully, there’s an easy way to create a batch file that will 1) enable hibernation mode and 2) set the computer to hibernate. You’ll need to download PSSHUTDOWN, a tiny (free) utility from the Windows Sysinternals website for this.
1) Download the PsTools collection from the web site above.
2) Unzip the PsTools.zip file and move the PSSHUTDOWN.EXE file to your Windows directory (you can delete the rest of the files from the PSTools kit, but there are some great utilities included with it that you should check out!)
3) Open Notepad, paste the following text into the window, and save the file as a .CMD file:
powercfg /hibernate on
The first line enables hibernation, while the second tells the computer to go into shutdown mode. If you wish, you could create a second batch file that has only “powercfg /hibernate off” in it, to disable hibernation with a single click.
Also, if you don’t want to download the PSSHUTDOWN tool, you can force hibernation by changing the second line of the batch file to:
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate
Note that the above should all be on one line; also, although this “alternate method” is built-in to Windows, I personally find the first option (psshutdown -h) easier to use.
Lastly, remember that you’ll actually need the space HIBERFILE.SYS will take up when you enable hibernation, so don’t go filling up your system partition! You’d need to quickly delete a bunch of stuff if the power goes out, which kind of defeats the hwole point of using a batch file to quickly enable hibernation!