How to Change the Way the Power Button Behaves in Windows 7
Normally, a press of a PC’s power button turns off the computer, whether or not Windows 7 is ready. To avoid confusing Windows 7 with an unexpected shutdown, consider changing the way your power button behaves in so that it doesn’t turn off your PC at all. By changing the power button to either sleep or hibernate, you are power down the computer faster while still protecting your files.
In order to keep Windows 7 running at its best, you need to give it time to prepare for a shutdown — it uses this time to tuck all the files away in their proper locations. When you protect Windows by preventing abrupt shutdowns, you eliminate conflicts in the system software and you also help the computer boot faster the next time.
Here's how you change the power button's behavior:
Click the Start button, choose Control Panel, and select the System and Security category.
Choose Power Options.
For quick access to this area, type Power Options into the Start menu’s Search box.
From the left-side panel, click Choose What the Power Button Does.
A window appears, offering a menu where you can tell your PC’s or laptop’s Power button to either Sleep, Hibernate, Shut Down your PC, or Do Nothing, which prevents people from turning off your PC with the power button.
Laptops owners also have the options to change the way the laptop behaves when it’s plugged in versus when it’s running on batteries and to change what happens when the lid is closed.
Choose an option from the drop-down lists and click the Save Changes button.
For extra security, click Require a Password to ensure that the person waking up your sleeping PC is authorized to do so.