Run as administrator - Add to PS1 File Context Menu in Windows 10  

Page 1 of 2 12 LastLast
    Run as administrator - Add to PS1 File Context Menu in Windows 10

    Run as administrator - Add to PS1 File Context Menu in Windows 10

    How to Add 'Run as administrator' to PS1 File Context Menu in Windows 10
    Published by Category: Customization
    08 Oct 2022
    Designer Media Ltd

    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
    Run as administrator - Add to PS1 File Context Menu in Windows 10-ps1_run_as_administrator.png



    Here's How:

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


    2 To Add "Run as administrator" to PS1 file Context Menu

    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'\""


    3 To Remove "Run as administrator" from PS1 file Context Menu

    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






  1. Posts : 3
    10
       #1

    First off, thank you! This is one of the best reg edits!

    I was trying to convert this.reg to use in a .bat using http://www.sordum.org/8478/reg-converter-v1-0/

    But it doesn't quite work. any tips for getting this to work in a .bat?

    again thank you!
      My Computer


  2. Posts : 68,667
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #2

    Hello treeman, :)

    Yeah, the PowerShell wrapper in it would put a damper on that.
      My Computers


  3. Posts : 4
    Windows 10
       #3

    Awesome reg file. Could you possibly make a context menu to Edit with PowerShell ISE as Admin?
    I found this, but I can't seem to get it to work Adding to the context menu | Tech thoughts
      My Computer


  4. Posts : 68,667
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #4

    Hello @michaeljt, and welcome to Ten Forums.

    I'll be happy to take a look to see what I may be able to come up with.

    For now, you could use "Open with" > "Choose another app" for this. You can select to "Open with" the %windir%\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe file with the "Always use this app" box unchecked.

    This way "Windows PowerShell ISE" will be added to the "Open with" context menu of the file type (ex: ".ps1") like below.

    It's not run as admin though.

    Run as administrator - Add to PS1 File Context Menu in Windows 10-open_with.jpg
      My Computers


  5. Posts : 4
    Windows 10
       #5

    Hello Brink and thank you. If you do ever find a way for Edit as Administrator that would be great.
      My Computer


  6. Posts : 68,667
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #6
      My Computers


  7. Posts : 61
    windows 10
       #7

    I launch the reg file and got the... "Add_PS1_Run_as_administrator.reg have been successfully added to the registry."

    but it doesnt add anything to the context menu
      My Computer


  8. Posts : 68,667
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #8

    chok said:
    I launch the reg file and got the... "Add_PS1_Run_as_administrator.reg have been successfully added to the registry."

    but it doesnt add anything to the context menu

    Hello chok,

    Just to verify, are you right clicking on a .ps1 file?
      My Computers


  9. Posts : 34
    windows 10
       #9

    I confirm it does not work on windows 1809. there is no menu entry for ps1 on the right click.
      My Computer


 

Tutorial Categories

Run as administrator - Add to PS1 File Context Menu in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:44.
Find Us




Windows 10 Forums