本帖最后由 tmplinshi 于 2011-7-20 13:43 编辑
需下载 nircmd- @echo off
-
- :: --------------------- 检测自己是否已运行 ---------------------
- set title=[%~nx0 is running]
-
- set /fi=/fi "imagename eq cmd.exe" /fi "windowtitle eq %title%"
- tasklist %/fi% 2>nul | findstr . >nul && (
- echo %~nx0 已经运行。按任意键退出...
- pause >nul
- exit /b
- )
-
- title %title%
- :: --------------------- / 检测自己是否已运行 ---------------------
-
- :: --------------------- 保持运行 ---------------------
- for /f "tokens=2" %%a in ('tasklist %/fi% /nh') do set pid=%%a
- start nircmd waitprocess /%pid% exec show "%~f0"
- :: --------------------- / 保持运行 ---------------------
-
- pause
复制代码
|