首页 > 解决方案 > 计划的 Powershell 脚本(WindowStyle Hidden)自动终止

问题描述

我需要安排在内部调用 bat 脚本并每分钟运行一次的 powershell 脚本。

script1.bat
一些写入 csv 文件的 echo 命令。

脚本2.ps1:

Invoke-RestMethod <URL>
./script1.bat

脚本3.ps1

./script2.ps1
sleep 60

所以 script3.ps1 在 cmd 中使用以下命令进行调度。

start /min powershell -WindowStyle Hidden -Command .\script2.ps1

所以预定的脚本(script3.ps1)按预期每分钟运行一次。但是几个小时后,脚本会自动终止。使用以下命令检查隐藏进程是否正在运行。

Get-WmiObject Win32_Process -filter "CommandLine LIKE '%powershell  -WindowStyle Hidden%'"

几个小时后我没有看到该过程运行。任何人都可以建议为什么后台隐藏的运行进程被杀死。

标签: windowspowershellscheduling

解决方案


推荐阅读