如何透過 AutoHotkey 開啟 PowerShell?

如何透過 AutoHotkey 開啟 PowerShell?

我在 Windows 7 上執行 AutoHotkey 1.0.48.05。

我想要 CTRL-ALT-P 開啟 PowerShell。

這是我到目前為止所擁有的:

^!p::
    Run %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Return

這是我得到的錯誤:

無法載入檔案 C:\Users[使用者名稱]\Documents\WindowsPowerShell\profile.ps1,因為在此系統上停用了腳本執行。請參閱“get-help about_signing”以了解更多詳細資訊。

我已經透過以管理員身分開啟 PowerShell ISE 並執行 來將執行原則設為 RemoteSigned Set-ExecutionPolicy RemoteSigned。 (看http://technet.microsoft.com/en-us/library/ee176949.aspx

我該如何解決這個問題?

更新:在 Windows 10 中,我甚至不需要 AutoHotKey。相反,我可以按WIN+ XA,然後按「是」。

答案1

如果您使用的是 64 位元版本的 Windows,則需要為 64 位元 powershell 和 32 位元設定執行策略。

這表示您需要在 32 位元 powershell 會話和 64 位元 powershell 會話中執行相同的命令。對於 32 位元 powershell,只需在「開始」功能表中搜尋「Windows Powershell (x86)」即可。

答案2

我最近遇到了同樣的問題。我沒有改變所有腳本的執行策略,而是這樣做:

#p::
^!p::
EnvGet, SystemRoot, SystemRoot
Run %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted,
return

相關內容