Add 'Edit or Run with' to PS1 File Context Menu in Windows 10  

Page 1 of 4 123 ... LastLast
    Add 'Edit or Run with' to PS1 File Context Menu in Windows 10

    Add 'Edit or Run with' to PS1 File Context Menu in Windows 10

    Published by Category: Customization
    16 Jun 2021
    Designer Media Ltd


    How to Add "Edit or Run with" PS1 File Context Menu in Windows 10


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

    This tutorial will show you how to add or remove a custom Edit or Run with cascading context menu for PowerShell .ps1 files for all users in Windows 10.

    The Edit or Run with cascading context menu includes the following items for PS1 files :

    • Run with PowerShell
    • Run with PowerShell as administrator
    • Run with PowerShell 7
    • Run with PowerShell 7 as administrator
    • Edit with PowerShell ISE
    • Edit with PowerShell ISE as administrator
    • Edit with PowerShell ISE (x86)
    • Edit with PowerShell ISE (x86) as administrator
    • Edit with Notepad
    • Edit with Notepad as administrator

    You must be signed in as an administrator to add or remove this context menu.

    It is required to install PowerShell 7 for the PowerShell 7 items in the context menu to work.


    EXAMPLE: "Edit or Run with" PS1 cascading context menu
    Add 'Edit or Run with' to PS1 File Context Menu in Windows 10-edit_or_run_with_ps1_context_menu.jpg



    Here's How:

    1 Do step 2 (add-right click), step 3 (add-Shift+right click) , or step 4 (remove) below for what you would like to do.


    2 To Add Right Click "Edit or Run with" PS1 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 5 below.

    Add_Edit_or_Run_with_to_PS1_context_menu.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\Open\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with]
    "MUIVerb"="Edit or Run with"
    "Extended"=-
    "SubCommands"=""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\001flyout]
    "MUIVerb"="Run with PowerShell"
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\001flyout\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-Run-with\shell\002flyout]
    "MUIVerb"="Run with PowerShell as administrator"
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\002flyout\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"\"& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\003flyout]
    "MUIVerb"="Run with PowerShell 7"
    "Icon"="pwsh.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\003flyout\Command]
    @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\004flyout]
    "MUIVerb"="Run with PowerShell 7 as administrator"
    "HasLUAShield"=""
    "Icon"="pwsh.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\004flyout\Command]
    @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"\"& {Start-Process pwsh.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\005flyout]
    "MUIVerb"="Edit with PowerShell ISE"
    "Icon"="powershell_ise.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\005flyout\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\006flyout]
    "MUIVerb"="Edit with PowerShell ISE as administrator"
    "HasLUAShield"=""
    "Icon"="powershell_ise.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\006flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start PowerShell_ISE.exe \"\"%1\"\"'  -Verb RunAs\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\007flyout]
    "MUIVerb"="Edit with PowerShell ISE (x86)"
    "Icon"="powershell_ise.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\007flyout\Command]
    @="\"C:\\WINDOWS\\syswow64\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\008flyout]
    "MUIVerb"="Edit with PowerShell ISE (x86) as administrator"
    "HasLUAShield"=""
    "Icon"="powershell_ise.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\008flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start C:\\WINDOWS\\syswow64\\WindowsPowerShell\\v1.0\\powershell_ise.exe \"\"%1\"\"'  -Verb RunAs\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\009flyout]
    "MUIVerb"="Edit with Notepad"
    "Icon"="notepad.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\009flyout\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\010flyout]
    "MUIVerb"="Edit with Notepad as administrator"
    "HasLUAShield"=""
    "Icon"="notepad.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\010flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start C:\\Windows\\System32\\notepad.exe \"\"%1\"\"'  -Verb RunAs\""


    3 To Add Shift + Right Click "Edit or Run with" PS1 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 5 below.

    Add_Shift+Edit_or_Run_with_to_PS1_context_menu.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\Open\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with]
    "MUIVerb"="Edit or Run with"
    "Extended"=""
    "SubCommands"=""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\001flyout]
    "MUIVerb"="Run with PowerShell"
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\001flyout\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-Run-with\shell\002flyout]
    "MUIVerb"="Run with PowerShell as administrator"
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\002flyout\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"\"& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\003flyout]
    "MUIVerb"="Run with PowerShell 7"
    "Icon"="pwsh.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\003flyout\Command]
    @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\004flyout]
    "MUIVerb"="Run with PowerShell 7 as administrator"
    "HasLUAShield"=""
    "Icon"="pwsh.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\004flyout\Command]
    @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"\"& {Start-Process pwsh.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\005flyout]
    "MUIVerb"="Edit with PowerShell ISE"
    "Icon"="powershell_ise.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\005flyout\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\006flyout]
    "MUIVerb"="Edit with PowerShell ISE as administrator"
    "HasLUAShield"=""
    "Icon"="powershell_ise.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\006flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start PowerShell_ISE.exe \"\"%1\"\"'  -Verb RunAs\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\007flyout]
    "MUIVerb"="Edit with PowerShell ISE (x86)"
    "Icon"="powershell_ise.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\007flyout\Command]
    @="\"C:\\WINDOWS\\syswow64\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\008flyout]
    "MUIVerb"="Edit with PowerShell ISE (x86) as administrator"
    "HasLUAShield"=""
    "Icon"="powershell_ise.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\008flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start C:\\WINDOWS\\syswow64\\WindowsPowerShell\\v1.0\\powershell_ise.exe \"\"%1\"\"'  -Verb RunAs\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\009flyout]
    "MUIVerb"="Edit with Notepad"
    "Icon"="notepad.exe"
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\009flyout\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\010flyout]
    "MUIVerb"="Edit with Notepad as administrator"
    "HasLUAShield"=""
    "Icon"="notepad.exe"
    
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with\shell\010flyout\Command]
    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start C:\\Windows\\System32\\notepad.exe \"\"%1\"\"'  -Verb RunAs\""


    4 To Remove "Edit or Run with" PS1 Context Menu

    This is the default setting

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

    Remove_Edit_or_Run_with_from_PS1_context_menu.reg

    Download

    (contents of REG file)
    Code:
    Windows Registry Editor Version 5.00
    
    [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit-Run-with]


    5 Save the .reg file to your desktop.

    6 Double click/tap on the downloaded .reg file to merge it.

    7 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

    8 You can now delete the downloaded .reg file if you like.


    That's it,
    Shawn Brink



  1. Paul Black's Avatar
    Posts : 14,329
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #1

    Another excellent Tutorial @Brink. Thanks for ALL your time and effort that you put into these.
      My Computer

  2. Brink's Avatar
    Posts : 59,190
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #2

    Paul Black said:
    Another excellent Tutorial @Brink. Thanks for ALL your time and effort that you put into these.
      My Computers


  3. Posts : 5
    Windows 10 Pro, Server 2016
       #3

    @Brink that is beautiful
      My Computer

  4. Brink's Avatar
    Posts : 59,190
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #4

    DrgnLrd said:
    @Brink that is beautiful
    I'm glad you like it. Thank you for requesting a context menu for this.
      My Computers


  5. Posts : 5
    Windows 10 Pro, Server 2016
       #5

    Just curious, but I went to change the default handler to ISE(x64) and it took the entire menu away. I changed the following line

    Code:
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    to have the same starting command as Open with ISE
    Code:
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    and it keeps it from working as well, changing the default handler back to Notepad brings it back though.

    Also, for some reason, the Notepad.exe icon just never shows, it is showing a generic windows icon.
      My Computer


  6. Posts : 447
    Win7 Pro X64, Win10 Pro x640
       #6

    Nice! My PowerShell Right-Click menu was getting a bit crowded. Thank you!
      My Computer


  7. Brink's Avatar
    Posts : 59,190
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #7

    DrgnLrd said:
    Just curious, but I went to change the default handler to ISE(x64) and it took the entire menu away. I changed the following line

    Code:
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
    @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""
    to have the same starting command as Open with ISE
    Code:
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    and it keeps it from working as well, changing the default handler back to Notepad brings it back though.

    Also, for some reason, the Notepad.exe icon just never shows, it is showing a generic windows icon.
    I tested with this below for the default "Open", and it works to open with ISE.

    Code:
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    Here's the .reg file for the above to test with:

    Add_Edit_or_Run_with_to_PS1_context_menu.reg
      My Computers

  8. Brink's Avatar
    Posts : 59,190
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #8

    bamajon1974 said:
    Nice! My PowerShell Right-Click menu was getting a bit crowded. Thank you!
      My Computers


  9. Posts : 5
    Windows 10 Pro, Server 2016
       #9

    Brink said:
    I tested with this below for the default "Open", and it works to open with ISE.

    Code:
    [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    Here's the .reg file for the above to test with:

    Add_Edit_or_Run_with_to_PS1_context_menu.reg
    Not sure why it didn't work when I edited it, but it worked right away when I merged that reg file.
      My Computer


 
Page 1 of 4 123 ... LastLast

Tutorial Categories

Add 'Edit or Run with' 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 01:10.
Find Us




Windows 10 Forums