从任务计划程序运行任务时,即使添加 -WindowsStylehidden,PowerShell 窗口也不会隐藏

问题描述 投票:0回答:1

我在 Windows 任务计划程序中创建了一个任务,它基本上是一个必须以交互模式运行的 PowerShell 脚本。该任务在 SYSTEM 帐户下运行。

在“操作”选项卡中的“程序/脚本”下,我添加了 ServiceUI.exe 的路径,例如

C:\***\***\ServiceUI.exe

在“添加参数”选项下,我添加了

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -Windowstyle hidden -NoProfile -Executionpolicy bypass -file "C:\**\PS1.ps1"

当我运行该任务时,PowerShell 窗口提示符会显示几分之一秒。

有人可以建议一种隐藏它的方法吗?

powershell vbscript windows-task-scheduler interactive-mode
1个回答
0
投票

我能够使用 vb 脚本解决该问题。

WScript.Quit CreateObject("WScript.Shell").Run("powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File " & PSscriptPath, 0, true)

在“操作”选项卡中的“程序/脚本”下,我有 ServiceUI.exe 的路径,例如,

C:**\ServiceUI.exe

在参数选项中添加了

wscript.exe "vbs script path"

PowerShell 提示不会出现,并且使用这些选项在 SYSTEM 帐户下的交互模式下任务可以完美运行。

© www.soinside.com 2019 - 2024. All rights reserved.