[英]Copy files with certain extension created within last half an hour with powershell
[英]In Powershell, how to run an executable for an hour, stop for half an hour, then repeat?
我在“ C:\\ Users \\ Admin \\ Desktop \\ scraper \\ work.exe”中有一个可执行文件,我想在Powershell中执行以下操作。
我希望有一个干净简单的解决方案。 我看过启动过程和等待过程都没有成功。 谢谢。
您可以启动该过程并获取PID,然后使用该ID稍后将其停止。 这将永远满足您的要求(在1时)。
While (1) {
$proc = Start-Process C:\Users\Admin\Desktop\scraper\work.exe -PassThru
Start-Sleep -Seconds (60*60)
Stop-Process $proc.Id -force
Start-Sleep -Seconds (30*60)
}
您可以使用Start-Sleep -s or -m
[Exampe and usage][1]https://technet.microsoft.com/en-us/library/ee177002.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.