Created
April 25, 2025 20:44
-
-
Save surgicalcoder/90427bb990351a43626273c6cbf82428 to your computer and use it in GitHub Desktop.
Run a powershell file on windows with double click
This file contains hidden or 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 | |
| ; Register PowerShell Script file type | |
| [HKEY_CLASSES_ROOT\.ps1] | |
| @="Microsoft.PowerShellScript.1" | |
| "Content Type"="text/plain" | |
| ; Create the PowerShell Script type | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1] | |
| @="PowerShell 7 Script" | |
| ; Set the icon for .ps1 files | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\DefaultIcon] | |
| @="C:\\Program Files\\PowerShell\\7\\pwsh.exe,0" | |
| ; Create the open command | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell] | |
| @="Open" | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open] | |
| @="Run with PowerShell 7" | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command] | |
| @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoProfile -Command \"$ErrorActionPreference = 'Stop'; $script = '%1'; try { Set-Location -LiteralPath (Split-Path -Parent $script); & $script } catch { Write-Host $_.Exception.Message -ForegroundColor Red }; Write-Host ''; Write-Host 'Press any key to exit...' -ForegroundColor Yellow; $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')\"" | |
| ; Add an edit command | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit] | |
| @="Edit PowerShell Script" | |
| [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command] | |
| @="notepad.exe \"%1\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment