Skip to content

Instantly share code, notes, and snippets.

@phillip-haydon
Created June 7, 2018 10:29
Show Gist options
  • Save phillip-haydon/46435fddc9d41e6e8bf614e44aa3495e to your computer and use it in GitHub Desktop.
Save phillip-haydon/46435fddc9d41e6e8bf614e44aa3495e to your computer and use it in GitHub Desktop.
Powershell - Disable Shutdown / Restart buttons on Windows
Install-Module -Name PolicyFileEditor -SkipPublisherCheck -Force
$UserDir = "$env:windir\system32\GroupPolicy\User\registry.pol"
# After manually setting the values in Local Group Policy Editor (gpedit.msc), extract the values our so we can set them
# Get-PolicyFileEntry -Path $UserDir -All
# Disable the Shutdown / Restart options
# http://brandonpadgett.com/powershell/Local-gpo-powershell/
# http://blog.willbeattie.com/2010/01/disabling-shut-down-button-on-windows.html
$RegPath = 'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
$RegName = 'NoClose'
$RegData = '1'
$RegType = 'DWord'
Set-PolicyFileEntry -Path $UserDir -Key $RegPath -ValueName $RegName -Data $RegData -Type $RegType
@deftoner
Copy link

this not work check out mine program : https://github.com/AnCarsenat/Disable-power-button

That's a nice "program" but that's not the power button they are discussing, this issue is about disabling the shutdown/restart option in the Start menu.

Yeah I saw this message back then, he just want to promote his script :D

@AnCarsenat
Copy link

Oh yeah sorry, did not read all the way, silly me, I did want to promote ;D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment