I want to execute a powershell script (ps1-file) with a hotkey on my keyboard (CTRL + SHIFT + F for instance).
I managed to create a shortcut of the script (right click in explorer > new > shortcut). The shortcut's target is: "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "PATH_TO_THE_SCRIPT" ".
When I execute the script manually (by double-clicking the shortcut), it works like a charm. But when I try to assign a "Shortcut key" in the Shortcut Properties (CTRL + SHIFT + F) and press the shortcut key I just defined, nothing happens. What's the matter?
I'm quite sure it has something to do with security policies. But I don't know what exactly it is.
This is my Execution-Policy:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser Unrestricted
LocalMachine Unrestricted
Any help is appreciated.
One of the quickest ways to start PowerShell in any modern version of Windows is to use the Run window. A fast way to launch this window is to press the Win + R keys on your keyboard. Then, type powershell and press the Enter key or click OK.
The fastest way to access most Windows software programs is through keyboard shortcuts. To quickly access the Run command dialog box, simply press the Windows key + R.
A great feature of the PowerShell ISE is that you can select one or more sections of code, press F8 and the highlighted section will run. You can also run a single line of code this way. You don't even need to select it all. If you press F8, then the ISE will run the line of code that contains your cursor.
In File Explorer (or Windows Explorer), right-click the script file name and then select "Run with PowerShell". The "Run with PowerShell" feature starts a PowerShell session that has an execution policy of Bypass, runs the script, and closes the session.
That's it. As soon as I move the shortcut file to the desktop and redefine the "shortcut key", the shortcut key works!
Is there a particular reason, why the shortcut has to be on the desktop?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With