Instantly share code, notes, and snippets.
Forked from SCP002/configure-ps1-context-menu.reg
Created
June 25, 2022 11:03
-
Star
(1)
1
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save mdavis199/acc52b633a7f1c082e4c3f44e3d6b7d2 to your computer and use it in GitHub Desktop.
Windows Registry: Run PowerShell scripts with double click. Various tweaks of context menu for .ps1 and .psm1 files. See coments for description.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
; WARNING: | |
; Uses Visual Studio Code as a standard editor. | |
; You might change it to your own with default file path, like: | |
; | |
; [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command] | |
; @="\"C:\\Windows\\System32\\notepad.exe\" \"%1\"" | |
; | |
; Or using path variables (%SystemRoot% etc.) for portability sake by | |
; creating REG_EXPAND_SZ default value: | |
; @=hex(2):... | |
; with binary representation of a value like: | |
; "%SystemRoot%\System32\notepad.exe" "%1" | |
; Tested with Windows 10 Pro 20H2, build 19042.928 | |
; ========================================================= SCRIPTS ========================================================= | |
; Associate .ps1 files with powershell scripts | |
; -------------------------------------------------------------------- | |
; Set default value to 'Microsoft.PowerShellScript.1' | |
[HKEY_CLASSES_ROOT\.ps1] | |
@="Microsoft.PowerShellScript.1" | |
; Fix open .ps1 files with any program except 'powershell.exe' or 'powershell_ise.exe' cause content menu settings breakage | |
; -------------------------------------------------------------------- | |
; Remove 'OpenWithProgids' | |
[-HKEY_CLASSES_ROOT\.ps1\OpenWithProgids] | |
; Change powershell scripts context menu behavior: Add, remove and change default items | |
; -------------------------------------------------------------------- | |
; Set default action to 'Open' | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell] | |
@="Open" | |
; Remove 'Run with PowerShell' | |
[-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0] | |
; Set 'Edit' action to open script with VSCode | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit] | |
"NoSmartScreen"="" | |
; REG_EXPAND_SZ value of: "%LocalAppData%\Programs\Microsoft VS Code\Code.exe" "%1" | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command] | |
@=hex(2):22,00,25,00,4c,00,6f,00,63,00,61,00,6c,00,41,00,70,00,70,00,44,00,61,\ | |
00,74,00,61,00,25,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,\ | |
5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,\ | |
00,20,00,43,00,6f,00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,\ | |
78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00 | |
; Set 'Open' action to run script | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open] | |
; REG_EXPAND_SZ value of: "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser -Force; & \"%1\"" | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command] | |
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\ | |
00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,\ | |
69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,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,20,\ | |
00,22,00,2d,00,43,00,6f,00,6d,00,6d,00,61,00,6e,00,64,00,22,00,20,00,22,00,\ | |
53,00,65,00,74,00,2d,00,45,00,78,00,65,00,63,00,75,00,74,00,69,00,6f,00,6e,\ | |
00,50,00,6f,00,6c,00,69,00,63,00,79,00,20,00,2d,00,45,00,78,00,65,00,63,00,\ | |
75,00,74,00,69,00,6f,00,6e,00,50,00,6f,00,6c,00,69,00,63,00,79,00,20,00,42,\ | |
00,79,00,70,00,61,00,73,00,73,00,20,00,2d,00,53,00,63,00,6f,00,70,00,65,00,\ | |
20,00,43,00,75,00,72,00,72,00,65,00,6e,00,74,00,55,00,73,00,65,00,72,00,20,\ | |
00,2d,00,46,00,6f,00,72,00,63,00,65,00,3b,00,20,00,26,00,20,00,5c,00,22,00,\ | |
25,00,31,00,5c,00,22,00,22,00,00,00 | |
; Add 'Run as administrator' | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\RunAs] | |
"HasLUAShield"="" | |
; REG_EXPAND_SZ value of: "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser -Force; & \"%1\"" | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\RunAs\Command] | |
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\ | |
00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,\ | |
69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,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,20,\ | |
00,22,00,2d,00,43,00,6f,00,6d,00,6d,00,61,00,6e,00,64,00,22,00,20,00,22,00,\ | |
53,00,65,00,74,00,2d,00,45,00,78,00,65,00,63,00,75,00,74,00,69,00,6f,00,6e,\ | |
00,50,00,6f,00,6c,00,69,00,63,00,79,00,20,00,2d,00,45,00,78,00,65,00,63,00,\ | |
75,00,74,00,69,00,6f,00,6e,00,50,00,6f,00,6c,00,69,00,63,00,79,00,20,00,42,\ | |
00,79,00,70,00,61,00,73,00,73,00,20,00,2d,00,53,00,63,00,6f,00,70,00,65,00,\ | |
20,00,43,00,75,00,72,00,72,00,65,00,6e,00,74,00,55,00,73,00,65,00,72,00,20,\ | |
00,2d,00,46,00,6f,00,72,00,63,00,65,00,3b,00,20,00,26,00,20,00,5c,00,22,00,\ | |
25,00,31,00,5c,00,22,00,22,00,00,00 | |
; ========================================================= MODULES ========================================================= | |
; Associate .psm1 files with powershell modules | |
; -------------------------------------------------------------------- | |
; Set default value to 'Microsoft.PowerShellModule.1' | |
[HKEY_CLASSES_ROOT\.psm1] | |
@="Microsoft.PowerShellModule.1" | |
; Fix open .psm1 files with any program except 'powershell.exe' or 'powershell_ise.exe' cause content menu settings breakage | |
; -------------------------------------------------------------------- | |
; Remove 'OpenWithProgids' | |
[-HKEY_CLASSES_ROOT\.psm1\OpenWithProgids] | |
; Change powershell modules context menu behavior: Add, remove and change default items | |
; -------------------------------------------------------------------- | |
; Set default action to 'Open' | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell] | |
@="Open" | |
; Remove 'Run with PowerShell' | |
[-HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\0] | |
; Set 'Edit' action to open module with VSCode | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\Edit] | |
"NoSmartScreen"="" | |
; REG_EXPAND_SZ value of: "%LocalAppData%\Programs\Microsoft VS Code\Code.exe" "%1" | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\Edit\Command] | |
@=hex(2):22,00,25,00,4c,00,6f,00,63,00,61,00,6c,00,41,00,70,00,70,00,44,00,61,\ | |
00,74,00,61,00,25,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,\ | |
5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,\ | |
00,20,00,43,00,6f,00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,\ | |
78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00 | |
; Set 'Open' action to open module with VSCode | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\Open] | |
"NoSmartScreen"="" | |
; REG_EXPAND_SZ value of: "%LocalAppData%\Programs\Microsoft VS Code\Code.exe" "%1" | |
[HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\Open\Command] | |
@=hex(2):22,00,25,00,4c,00,6f,00,63,00,61,00,6c,00,41,00,70,00,70,00,44,00,61,\ | |
00,74,00,61,00,25,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,\ | |
5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,\ | |
00,20,00,43,00,6f,00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,\ | |
78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00 | |
; Remove 'Run as administrator' | |
[-HKEY_CLASSES_ROOT\Microsoft.PowerShellModule.1\Shell\RunAs] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment