- @echo off
- for /l %%a in (1 0 1) do (
- pv a.exe 2>nul||start "" "a.exe"
- pv -r0 -d1000 -x a.exe 2>nul
- )
复制代码 先检测a.exe是否运行,若无,则运行a,exe。若有,继续向下执行:
pv -r0 -d1000 -x a.exe 2>nul
-d1000: 每1000ms检测一次a.exe
-x 等待程序结束: 若发现a.exe运行中,则继续循环检测,一直到a.exe被结束才执行下面的语句goto loop- Modes:
- -s --summary show usage for the specified MODULE
- -h,-? --help display this help information
- Actions:
- -k --kill kill process
- -a --activate brings process main window in the foreground
- -c --close close (send WM_CLOSE) to the PROCESS
- -p[nihr] --priority set priority to "Normal", "Idle", "High", "Real Time"
- [ba] "Below Normal" and "Above Normal" only on W2K or higher
- Output Options:
- -e, --extend show additional information if available
- -l, --long show command line (can also be a filter)
- -q, --quiet supress headers and produce a tab-separated list
- -b --bare show process ID only ()
- Input Options:
- -f, --force never prompt
- -i, --id use process ID instead of the PROCESS name
- Filters:
- -l[mask] --long include processes with command line matching mask
- -w[mask] --window show processes with visible windows matching mask,
- -e includes in search also invisible windows
- -u[mask] --usage show processes using modules that matches mask
- -t[root] --tree display process tree starting starting from the root
- Extra Information Options:
- -g --getenv get startup environment for the PROCESS
- -m --module show modules used by specified PROCESS
- Execution Options:
- -d[time] --delay delay time in milliseconds before executing command
- -r[err] --repeat repeat command in a cycle, while (%ERRORLEVEL% > err)
- -n --number %ERRORLEVEL% = negated number of matched processes
- -x[a] --exit wait for the process completion (exit)
- 'a' flag waits for all processes, -d sets time-out
- -@[file_name] read arguments from specified file or from
- standard input after processing the command line
- Arguments can contain '*' and '?' wildcards.
- Use return code (%ERRORLEVEL%) in batch files:
- 0 - process found (negated number of processes if -n is specified)
- 1 - empty result set, 2 - programm error
- Examples:
- pv myprocess.exe get process ID for myprocess.exe.
- pv -e get extended list of running processes.
- pv -k sleep* kill all processes starting with "sleep"
- pv -m -e explorer.exe get extended information about explorer's modules
- pv -u oleaut*.dll list of all processes that use matching dll
- pv -ph w*.exe set priority to hight for all matching processes
- pv explorer.exe -l"*/S" looks for explorer process with /S switch
- pv -r0 -d2000 calc.exe "2>nul" checks every 2 seconds if calc.exe is running
复制代码
[ 本帖最后由 pusofalse 于 2008-10-28 16:06 编辑 ] |