Disable physical power button

Hey everyone so I would like to disable the physical power button on some machines I support. The users have a habit of pressing the power button even though we have disabled the software shutdown option through GPO. So is there a way to set this in powershell?

I have tried this:

powercfg -setacvalueindex db310065-829b-4671-9647-2261c00e86ef 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 0


and this:

powercfg -setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 0

The first is a Power scheme under config man and the second is under High performance.

These two commands appear to change the setting but when I press the power button the machine still shuts off.

I have also tried this script:

Function Set-OSCPowerButtonAction
{
	Param
	(
		[Parameter(Mandatory = $true,Position = 0)] 
		[ValidateSet("LogOff", "SwitchUser", "Lock","Restart","Sleep","Hibernate","ShutDown")]
		[String]$Action
	)
	Switch($Action)
	{
		"SwitchUser"  	{	ChangebuttonAction 0x00000100 	}
		"LogOff"    	{	ChangebuttonAction 0x00000001	}
		"Lock" 			{	ChangebuttonAction 0x00000200	}
		"Restart" 		{	ChangebuttonAction 0x00000004	}
		"Sleep" 		{	ChangebuttonAction 0x00000010	}
		"Hibernate" 	{	ChangebuttonAction 0x00000040	} 
		"Shutdown" 		{	ChangebuttonAction 0x00000002 	}
	}
	GetChoice
}


Function ChangebuttonAction($value)
{
	$Regpath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
	$KetExist = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_PowerButtonAction" -ErrorAction SilentlyContinue
	If($KetExist)
	{
	
		Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"  -Name "Start_PowerButtonAction"  -Value $value 
	}
	Else 
	{
		New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"  -Name "Start_PowerButtonAction"  -Value $value  -PropertyType Dword
	}
}

Function GetChoice
{
    #Prompt message
    $Caption = "Restart the computer."
    $Message = "It will take effect after restart, do you want to restart right now?"
    $Choices = [System.Management.Automation.Host.ChoiceDescription[]]`
    @("&Yes","&No")
    [Int]$DefaultChoice = 0
    $ChoiceRTN = $Host.UI.PromptForChoice($Caption, $Message, $Choices, $DefaultChoice)
    Switch ($ChoiceRTN)
    {
        0 	{shutdown -t 0 -r }
        1  	{break}
    }
}

None of these seem to work is this possible to do? Thanks for any help!

August 28th, 2015 10:06am

You cannot change the power button action with the OS.  You have to change the BIOS settings.  Contact the system vendor to get info on this. For UEFI BIOS machines you can  use BCDEdit to alter this setting.

The setting is vendor specific and usually not supportable on non UEFI systems.  Some system vendors supply a utility to edit the BIOS.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 10:28am

Note that the scrip you are trying to use only works on some laptops with specific vendor support for session control.  This is mostly only available on "Surface" tablets and some laptops.

On newer HP and De desktops I believe there is support for using Group Policy to change this.

Since this requires a BIOS change on many machines a normal user cannot alter the setting.  On system shipped with this support and where the default setting is to alert the system then it should work with all Windows 8 and later systems and some Windows 7 systems.  Check you hardware documentation to verify support.

August 28th, 2015 10:36am

Alright thanks for the reply JRV I'll check on that tool. Thanks again.
Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 10:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics