How to Add 'Run as administrator' to PS1 File Context Menu in Windows 10
Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For example, when a program that you are trying to run is giving you a Access Denied or No Permission type error.
When you right click on application files, you can use the Run as administrator context menu item to run the app with elevated rights (full administrator access token).
A PS1 file is a script, or cmdlet, used by Windows PowerShell.
This tutorial will show you how to add or remove Run as administrator from the context menu of PowerShell .ps1 files for all users in Windows 10 and Windows 11.
You must be signed in as an administrator to add or remove this context menu.
EXAMPLE: "Run as administrator" in context menu of PS1 files
Here's How:
1 Do step 2 (add) or step 3 (remove) below for what you would like to do.
The .reg file in this step also includes the contents of the ps1.reg file here to restore the default associations for .ps1.
A) Click/tap on the Download button below to download the file below, and go to step 4 below.
Add_PS1_Run_as_administrator.reg
Download
(Contents of .reg file)
Code:Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\.ps1] [HKEY_CLASSES_ROOT\.ps1] @="Microsoft.PowerShellScript.1" [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1] [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1] "EditFlags"=dword:00020000 "FriendlyTypeName"=hex(2):40,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,\ 00,72,00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,\ 33,00,32,00,5c,00,77,00,69,00,6e,00,64,00,6f,00,77,00,73,00,70,00,6f,00,77,\ 00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,\ 5c,00,70,00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,65,\ 00,78,00,65,00,22,00,2c,00,2d,00,31,00,30,00,33,00,00,00 [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\DefaultIcon] @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\",1" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell] @="Open" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0] "MUIVerb"=hex(2):40,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,\ 6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,\ 00,5c,00,77,00,69,00,6e,00,64,00,6f,00,77,00,73,00,70,00,6f,00,77,00,65,00,\ 72,00,73,00,68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,5c,00,70,\ 00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,65,00,78,00,\ 65,00,20,00,22,00,2c,00,2d,00,31,00,30,00,38,00,00,00 [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command] @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\"" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit] "NoSmartScreen"="" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command] @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\"" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command] @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\"" [-HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1] [-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ps1] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ps1\OpenWithList] "a"="powershell_ise.exe" "b"="bca" "c"="powershell.exe" "d"="abcd" "e"="abcde" "MRUList"="fabcde" "f"="notepad.exe" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ps1\OpenWithProgids] "Microsoft.PowerShellScript.1"=hex(0): [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas] [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas] "HasLUAShield"="" [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas\command] @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
This is the default setting.
A) Click/tap on the Download button below to download the file below, and go to step 4 below.
Remove_PS1_Run_as_administrator.reg
Download
(Contents of .reg file)
Code:Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas]
4 Save the .reg file to your desktop.
5 Double click/tap on the downloaded .reg file to merge it.
6 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.
7 You can now delete the downloaded .reg file if you like.
That's it,
Shawn Brink
Related Tutorials
- How to Run an App as Administrator in Windows 10
- How to Add or Remove 'Run as administrator' Context Menu in Windows 10
- How to Add 'Run as administrator' to MSI File Context Menu in Windows 10
- How to Add 'Run as administrator' to VBS File Context Menu in Windows 10
- How to Add 'Open PowerShell window here as administrator' context menu in Windows 10
- How to Set PowerShell Script Execution Policy in Windows 10
- How to Add Windows PowerShell Script to New Context Menu in Windows 10
- How to Add Edit with PowerShell ISE as administrator context menu in Windows 10
- How to Add Edit with PowerShell ISE x86 as administrator in Windows 10
- How to Add "Edit or Run with" PS1 File Context Menu in Windows 10