1. 計劃任務設定(執行身份, 許可權等)
以開機腳本為例
只需要勾選'不管是否登入都要執行'及'最高許可權執行'
觸發程式:
操作:
思路: cmd.exe 呼叫 powershell.exe 再加引數指定 xxx.ps1 檔案
啟動程式: C:WindowsSystem32cmd.exe
若想正常的執行ps1腳本, 需要proper powershell.exe 的引數
-File 引數 腳本完全路徑 String型別
-ExecutionPolicy 執行策略 可選值 Restricted / AllSigned / RemoteSigned / Unrestricted / Bypass / Undefined
-Noprofile 設定檔
-NonInteractive 不互動
-NoLogo No Copyright 提醒
新增引數: /C C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -File "C:ProgramDataxxxx.ps1"
cmd /c 執行完關閉, cmd /k 執行完保留