我不希望运行脚本时弹出蓝色窗口。 应该像在公共场所的屏幕一样在后台进行操作:)
我尝试过-Argument '-NoProfile -WindowStyle Hidden
我的完整代码是:
function Create-Schedule{
$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument '-NoProfile -WindowStyle Hidden -command "& {C:\PowerPointScript\myscript.ps1}"'
$trigger = New-ScheduledTaskTrigger -Once -At (get-date) -RepetitionInterval (New-TimeSpan -Minutes 1)
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Powerpoint" -Description "Run Powerpoint download script every 5th min"
}
答案 0 :(得分:0)
解决此问题的唯一方法似乎是在任务计划程序中计划此.VBS。
command = "powershell.exe -nologo -command C:\Scripts\YourScript.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0