【问题标题】:scripts to manage service start under windowswindows下管理服务启动的脚本
【发布时间】:2013-01-17 16:13:01
【问题描述】:

我目前正在寻找在 Windows 下管理服务启动/停止的最佳方法。

我会使用windows提供的task sheduler在特定时间启动一个脚本。

脚本的目标是:

  • 检查进程“X”是否正在运行
  • 如果没有服务 Y 可以启动
  • 如果是,请在一小时后检查进程“X”是否仍在运行

还有什么是最好的语言呢? Python 是个不错的选择吗?

塞巴斯蒂安

【问题讨论】:

  • 我会推荐 WMI 在 Windows 下管理服务。但这对于您想要的东西来说可能有点过头了......

标签: windows service process task


【解决方案1】:

这是一个批处理脚本(另存为.bat)

tasklist /nh /fi "imagename eq x.exe" | find /i "x.exe" >nul && goto :HOURCHECK || net start Y
exit >nul    
:HOURCHECK
timeout /t 3600
tasklist /nh /fi "imagename eq x.exe" | find /i "x.exe" >nul && REM Running || REM Not Running

只需替换我的REM cmets 即可在一小时后检查时执行您想要的操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-07
    • 2014-01-28
    • 2014-07-02
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多