- #WHEN I RUN POWERSHELL SCRIPT IT CLOSES RIGHT AWAY DOWNLOAD#
- #WHEN I RUN POWERSHELL SCRIPT IT CLOSES RIGHT AWAY WINDOWS#
To make the right click work inside a folder meaning right clicking an empty space inside a folder, repeat the steps but this time, the registry location is:Ĭ:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.
#WHEN I RUN POWERSHELL SCRIPT IT CLOSES RIGHT AWAY WINDOWS#
#WHEN I RUN POWERSHELL SCRIPT IT CLOSES RIGHT AWAY DOWNLOAD#
See my blog for more information and a script to download that will make the registry change for you. ps1 file and choose Run with PowerShell (shows up depending on which Windows OS and Updates you have installed).ĭefault Value: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') & \"%1\"" Registry Key: HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Commandĭescription: Key used when you right-click a. ps1 file and choose Open With -> Windows PowerShell.ĭefault Value: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "%1"ĭesired Value: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "& \"%1\"" Registry Key: HKEY_CLASSES_ROOT\Applications\powershell.exe\shell\open\commandĭescription: Key used when you right-click a. Global Fix: Change your registry key by adding the -NoExit switch to always leave the PowerShell Console window open after the script finishes running.Per-script Fix: Add a prompt for input to the end of your script file.PowerShell -NoExit "C:\SomeFolder\SomeScript.ps1" One-time Fix: Run your script from the PowerShell Console, or launch the PowerShell process using the -NoExit switch.You basically have 3 options to prevent the PowerShell Console window from closing, that I describe in more detail on my blog post.