Windows 11 PowerShell 腳本雙擊執行方法

這篇文章將介紹如何在 Windows 11 上讓 PowerShell 腳本(.ps1 檔案)雙擊執行。以下是操作過程:

1. 下載並解壓縮 SetUserFTA 工具:https://kolbi.cz/SetUserFTA.zip

2. 以管理員身份打開 CMD,執行以下指令(使用 Windows PowerShell):

ftype Microsoft.PowerShellScript.1="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -ExecutionPolicy Bypass -f "%1"

3. 使用 SetUserFTA 工具,給予參數執行:

SetUserFTA.exe .ps1 Microsoft.PowerShellScript.1

若選擇使用 PowerShell 7,將第二步驟指令替換為:

ftype Microsoft.PowerShellScript.1="C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -ExecutionPolicy Bypass -f "%1"

完成上述操作後,即可在 Windows 11 上雙擊 .ps1 檔案進行執行。

參考資料:
https://www.elevenforum.com/t/run-ps1-files-double-click-on-windows-11.2433/

Facebook 留言

Posted in 軟體筆記 and tagged .

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *