If you’re like most people, you probably hit the power button on your computer a few times in a day. But if you happen to hit it accidentally, there are a few things you can do to keep your Windows 7 PC running smoothly. First, make sure that your computer is off. If it is, pressing the power button will turn it back on. Second, try to use an empty battery or another power outlet to turn off your computer. Finally, try not to touch your computer screen too much—this can cause it to heat up and make it difficult to type or use the mouse.
Open Control Panel and select Power Options, then on the left side click on Choose what the power button does.
Then click on the dropdown box and select Do Nothing from the menu and click on Save changes.
From the dropdown list you can also select Shutdown, Sleep or Hibernate. But, if you are annoyed when you accidently hit the button and it shuts down, choosing Do Nothing will keep it running.