|
|
发表于 2015-7-2 16:45:22
|
显示全部楼层
本帖最后由 flyinnet9 于 2015-7-2 16:47 编辑
2,7,12,17行- @echo off
- setlocal enabledelayedexpansion
- sc stop LazyStopService
- ping -n 12 127.0.0.1 >nul 2>nul
- for /f %%a in ('wmic SERVICE where name^="LazyStopService" get ProcessId^|findstr "[0-9]"') do (
- tasklist /fi "pid eq %%a" |find "%%a" 2>nul
- if !errorlevel!== 0 (
- echo one error
- sc stop LazyStopService
- ping -n 12 127.0.0.1 >nul 2>nul
- tasklist /fi "pid eq %%a" |find "%%a" 2>nul
- if !errorlevel! == 0 (
- echo two error
- sc stop LazyStopService
- ping -n 10 127.0.0.1 >nul 2>nul
- tasklist /fi "pid eq %%a" |find "%%a" 2>nul
- if !errorlevel! == 0 (
- echo three error
- taskkill /F /PID %%a
- )
- )
- )
- )
- echo haha
复制代码 这样应该就可以了,不过System Idle Process服务的PID貌似是0,wmic取PID的时候,如果服务未启动,返回也是0,最好判断一下 |
评分
-
查看全部评分
|