使用键盘热键启动Powershell脚本 [英] Launch powershell script with keyboard hotkey
问题描述
我想用键盘上的热键(例如CTRL + SHIFT + F)执行Powershell脚本(ps1-文件).
I want to execute a powershell script (ps1-file) with a hotkey on my keyboard (CTRL + SHIFT + F for instance).
我设法创建了脚本的快捷方式(在资源管理器中右键单击>新建>快捷方式).快捷方式的目标是:%SystemRoot%\ system32 \ WindowsPowerShell \ v1.0 \ powershell.exe -ExecutionPolicy绕过-文件" PATH_TO_THE_SCRIPT".
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" ".
当我手动执行脚本(通过双击快捷方式)时,它就像一个超级按钮.但是,当我尝试在快捷方式属性(CTRL + SHIFT + F)中分配快捷键"并按我刚刚定义的快捷键时,什么也没有发生.怎么了?
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.
这是我的执行政策:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser Unrestricted
LocalMachine Unrestricted
感谢您的帮助.
推荐答案
就是这样.将快捷方式文件移到桌面并重新定义快捷方式键"后,快捷方式键就起作用了!
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?
这篇关于使用键盘热键启动Powershell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!