Reputation: 1100
I am trying to launch a PowerShell script using keyboard shortcuts. My current script (super-simple, just prompts a yes/no popup) looks like this:
$a = new-object -comobject wscript.shell
$a.popup("Here's a test script", 0,"Title goes here", 4)
To make sure that it wasn't any lookup issues, I put both the script and the shortcut to the script on the desktop, namely:
The Shortcut has the following settings in the properties:
Target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File 'C:\Users\me\Desktop\ShortcutTest.ps1' Start in: C:\Users\me\Desktop Shortcut key: Ctrl + Alt + Q
the problem is when I press the shortcut it successfully starts a PowerShell window, but it immediately closes the instance.
Troubleshooting so far
If anyone has any tips on how I could solve this, or at least troubleshoot further, it would be greatly appreciated!
Upvotes: 2
Views: 1442
Reputation: 443
Try this:
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -
WindowStyle Hidden -ExecutionPolicy ByPass -File
'C:\Users\me\Desktop\ShortcutTest.ps1'
Upvotes: 2