Accounts Add Run as administrator to Context Menu of PS1 Files in Windows 11


  • Staff
PS1_banner.png

This tutorial will show you how to add or remove the Run as administrator context menu item for .ps1 files for all users in Windows 10 and Windows 11.

Windows runs desktops apps and application files (ex: .bat, .cmd, .exe, and .msc file types) in user mode by default without elevated administrator rights unless it prompts you with UAC to run elevated (highest privileges).

When you use Run as administrator on a desktop app or application file, you are allowing it to run with full administrator access to everything on the computer. This means you are giving it special permissions to access restricted parts of the computer that would otherwise be off-limits. This could be a potential security risk if not a trusted app or application file, but sometimes "Run as administrator" is necessary for a trusted app or application file to run properly if it requires elevated rights for full access.

A .ps1 file is a script, or "cmdlet," used by Windows PowerShell.


You must be signed in as an administrator to add, remove, and use the Run as administrator context menu for .ps1 files.



EXAMPLE: "Run as administrator" context menu for PS1 files

PS1_Run_as_administrator_context_menu-1.png
PS1_Run_as_administrator_context_menu-2.png



Here's How:

1 Do step 2 (add) or step 3 (remove) below for what you would like to do.

2 Add Run as administrator to Context Menu of PS1 Files

A) Click/tap on the Download button below to download the file below, and go to step 4 below.​

Add_Run_as_administrator_to_PS1_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\runas]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\runas\command]
@="powershell.exe \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""

3 Remove Run as administrator from Context Menu of PS1 Files

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_Run_as_administrator_from_PS1_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\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


 

Attachments

  • PS1.png
    PS1.png
    10.6 KB · Views: 57
  • Add_Run_as_administrator_to_PS1_context_menu.reg
    1,012 bytes · Views: 144
  • Remove_Run_as_administrator_from_PS1_context_menu.reg
    566 bytes · Views: 185
Last edited:
Back
Top Bottom