Open Power Options by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Security, and then clicking Power Options.
On the Select a power plan page, click Change plan settings for the plan that you want to change.
On the Change settings for the plan page, click Change advanced power settings.
On the Advanced settings tab, expand Power buttons and lid, expand Power button action, choose what you want your computer to do when you press the power button, and then click OK.
If you have a laptop, you can choose separate settings for when your laptop is running on battery and when it's plugged in.