Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种方法来杀死匹配某个名称的进程,如果(且仅当)它们的正常运行时间为 4 小时以上
然后我计划每隔一小时左右安排一次脚本,以检测并杀死符合我的标准的进程。
我一直在用谷歌搜索批处理、powershell 和 vbscripts 的解决方案,但没有找到任何符合我需求的东西。任何帮助将不胜感激!
排序:
Get-Process -name process_name_goes_here | ForEach-Object {If((New-TimeSpan -Start (get-process -Id $_.Id).StartTime).Hours -ge 4){Stop-Process $_.Id -force}}