Skip to content

Instantly share code, notes, and snippets.

@maokwen
Last active July 24, 2025 00:15
Show Gist options
  • Select an option

  • Save maokwen/94a1bbd7b94e40588390034f26f66c8e to your computer and use it in GitHub Desktop.

Select an option

Save maokwen/94a1bbd7b94e40588390034f26f66c8e to your computer and use it in GitHub Desktop.
Take Ownership Menu Hacks
if((Test-Path -LiteralPath "HKLM:\SOFTWARE\Classes\*\shell\runas") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\*\shell\runas" -force -ea SilentlyContinue };
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Classes\*\shell\runas' -Name '(default)' -Value 'Take Ownership' -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Classes\*\shell\runas' -Name 'NoWorkingDirectory' -Value '' -PropertyType String -Force -ea SilentlyContinue;
Remove-Item -LiteralPath "HKLM:\SOFTWARE\Classes\*\shell\runas" -force;
Remove-Item -LiteralPath "HKLM:\SOFTWARE\Classes\Directory\shell\runas" -force;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment