[英]VBScript will not run from Powershell script that runs from Windows Task Scheduler
[英]Windows Task Scheduler not starting program from Powershell script
我对 powershell 和服务器管理非常陌生。 我创建了一个简单的 powershell 脚本来停止和启动一个程序。 该脚本在我手动运行时可以正常工作,但是当 Windows 任务计划程序运行它时,如果程序正在运行,它将停止程序,但不会启动它。
Windows 任务计划程序报告“此操作已成功完成。(0x0)”
我在脚本上设置了成绩单,它也没有报告任何错误。
我的任务设置如下;
User; Administrator
Run whether user is logged on or not
Run with highest privledges is checked
Configure for: Windows 7, Windows Server 2008 R2
扳机:
Start one time
Repeat every 5 minutes indefinitely
行动:
Program/script:
powershell.exe
Add arguments: -Executionpolicy Bypass -file "C:\DiscordIntegratorBot\restart.ps1"
restart.ps1 内容:
start-transcript "c:\temp\script.log"
$processname = Get-Process -Name "DiscordIntegratorBot"
if ($processname) {
Stop-Process -Name $processname.Name -Force
}
Start-Process -FilePath "C:\DiscordIntegratorBot\DiscordIntegratorBot.exe"
stop-transcript
script.log 内容:
**********************
Windows PowerShell transcript start
Start time: 20200804113001
Username: NS1001457\Administrator
RunAs User: NS1001457\Administrator
Configuration Name:
Machine: NS1001457 (Microsoft Windows NT 10.0.17763.0)
Host Application: powershell.exe -Executionpolicy Bypass -file C:\DiscordIntegratorBot\restart.ps1
Process ID: 6312
PSVersion: 5.1.17763.1007
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.1007
BuildVersion: 10.0.17763.1007
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is c:\temp\script.log
**********************
Windows PowerShell transcript end
End time: 20200804113001
**********************
我不知道现在可能是什么问题,并感谢任何帮助。
经过更多的谷歌搜索后,我能够解决自己的问题..
将任务设置为“无论用户是否登录都运行”意味着应用程序在后台运行。 我正在检查程序 GUI 是否弹出,而不是进程 window。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.