How can I replace function of shutdown button with hibernate?

When you say power button, are you talking about the physical button on the computer case, or the power button icon on the start menu?

For Windows 7

Physical Button - Click start and type power options and click change what power buttons do and change it there enter image description here

Start Menu Icon - Right click the start button and click properties and in the start menu tab choose what the power button action is

enter image description here


Or use the methods described in the MS Documentation