My end goal is to create a keyboard shortcut that runs a powershell script. I followed what this guy is doing here. Right now, when I run the script from a PowerShell terminal, everything works just fine. But when I run it from the shortcut by double-clicking in the File Explorer (or keyboard shortcut), a new window appears with some kind of text in red but the window disappears before I have time to read anything. I'm sure I could fix the issue if I could read the message, but the window disappears too quickly. My .ps1 script and shortcut are saved to the Desktop.
I found this article that suggests adding the -NoExit
switch, but this does not fix the issue for me.
I have tried changing the Execution Policy to Bypass
and Unrestricted
and neither made a difference.
I tried modifying my script to pause on the first line of code, but it doesn't get that far so I assume the issue is not with my script.
The shortcut's properties:
Target: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File C:\Users\%UserName%\Desktop\<script>.ps1
Start in: C:\Users\%UserName%\Desktop\
I need to know why my script isn't running.
Please let me know what other information I left out and thanks in advance.