How to make a Windows computer logoff when press power button?

Solution
I don't think you can do that with the power button but you can change how the shutdown button behaves or create a shortcut to just Shutdown and Logout from the desktop and or with a hotkey.

Right click on your desktop.
Click New then Shortcut
Type the following

For a Force log off

shutdown.exe /L /F

For a Log off with timer - Substitute ## in the command below with a number between 0-315360000 for how many seconds you want the time-out period to be before log off

shutdown.exe /L /F /T ##

For a Log off with timer and comment - Substitute Your comment here in the command below with a shutdown message up to 512 characters within quotes that you would like to see in the pop-up dialog when using the shutdown...

delaro

Judicious
Ambassador
I don't think you can do that with the power button but you can change how the shutdown button behaves or create a shortcut to just Shutdown and Logout from the desktop and or with a hotkey.

Right click on your desktop.
Click New then Shortcut
Type the following

For a Force log off

shutdown.exe /L /F

For a Log off with timer - Substitute ## in the command below with a number between 0-315360000 for how many seconds you want the time-out period to be before log off

shutdown.exe /L /F /T ##

For a Log off with timer and comment - Substitute Your comment here in the command below with a shutdown message up to 512 characters within quotes that you would like to see in the pop-up dialog when using the shutdown shortcut. The message will only be seen for however long you set the time delay to be.

shutdown.exe /L /F /T ## /C "Your comment here"

To add a Shortcut Key to this, right click on the icon and hit properties. Then add whatever shortcut key you want, I use CTRL+ SHIFT + L.

.....
To change how the Shutdown button reacts "Win 7"

Click on Start button
Right click on the Shut down button and click on Properties

The Taskbar and Start Menu Properties page will open, beside the Power button action, click on the drop down list and you will find the other actions that can be selected and can replace the Shut down button.

You can change Shutdown button action to :

- Switch user
- Log off
- Lock
- Restart
- Sleep

Make your selection and then click on the OK button


I use the Desktop Icon and Hotkey myself



 
Solution