[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @pv -r0 -d1000 进程>nul 2>nul&&shutdown -s -t 10
复制代码
借助第三方工具pv.exe,每1秒钟检测一次,检测到之后提示10秒后关机。
pv.exe:http://bbs.bathome.net/thread-1864-1-1.html
1

评分人数

心绪平和,眼藏静谧。

TOP

当然如此,已经说明pv是第三方工具,需要下载。- -|||||||||||||
心绪平和,眼藏静谧。

TOP

回复 9楼 的帖子

pv xx.exe 2>nul||start "" "a.exe"
心绪平和,眼藏静谧。

TOP

  1. @echo off
  2. for /l %%a in (1 0 1) do (
  3.      pv a.exe 2>nul||start "" "a.exe"
  4.      pv -r0 -d1000 -x a.exe 2>nul
  5. )
复制代码
先检测a.exe是否运行,若无,则运行a,exe。若有,继续向下执行:

pv -r0 -d1000 -x a.exe 2>nul
-d1000: 每1000ms检测一次a.exe
-x 等待程序结束: 若发现a.exe运行中,则继续循环检测,一直到a.exe被结束才执行下面的语句goto loop
  1. Modes:
  2.   -s       --summary   show usage for the specified MODULE
  3.   -h,-?    --help      display this help information
  4. Actions:
  5.   -k       --kill      kill process
  6.   -a       --activate  brings process main window in the foreground
  7.   -c       --close     close (send WM_CLOSE) to the PROCESS
  8.   -p[nihr] --priority  set priority to "Normal", "Idle", "High", "Real Time"
  9.     [ba]               "Below Normal" and "Above Normal" only on W2K or higher
  10. Output Options:
  11.   -e,      --extend    show additional information if available
  12.   -l,      --long      show command line (can also be a filter)
  13.   -q,      --quiet     supress headers and produce a tab-separated list
  14.   -b       --bare      show process ID only ()
  15. Input Options:
  16.   -f,      --force     never prompt
  17.   -i,      --id        use process ID instead of the PROCESS name
  18. Filters:
  19.   -l[mask] --long      include processes with command line matching mask
  20.   -w[mask] --window    show processes with visible windows matching mask,
  21.                        -e includes in search also invisible windows
  22.   -u[mask] --usage     show processes using modules that matches mask
  23.   -t[root] --tree      display process tree starting starting from the root
  24. Extra Information Options:
  25.   -g       --getenv    get startup environment for the  PROCESS
  26.   -m       --module    show modules used by specified PROCESS
  27. Execution Options:
  28.   -d[time] --delay     delay time in milliseconds before executing command
  29.   -r[err]  --repeat    repeat command in a cycle, while (%ERRORLEVEL% > err)
  30.   -n       --number    %ERRORLEVEL% = negated number of matched processes
  31.   -x[a]    --exit      wait for the process completion (exit)
  32.                         'a' flag waits for all processes, -d sets time-out
  33.   -@[file_name]        read arguments from specified file or from
  34.                        standard input after processing the command line
  35. Arguments can contain '*' and '?' wildcards.
  36. Use return code (%ERRORLEVEL%) in batch files:
  37.     0 - process found (negated number of processes if -n is specified)
  38.     1 - empty result set, 2 - programm error
  39. Examples:
  40.   pv myprocess.exe        get process ID for myprocess.exe.
  41.   pv -e                   get extended list of running processes.
  42.   pv -k sleep*            kill all processes starting with "sleep"
  43.   pv -m -e explorer.exe   get extended information about explorer's modules
  44.   pv -u oleaut*.dll       list of all processes that use matching dll
  45.   pv -ph w*.exe           set priority to hight for all matching processes
  46.   pv explorer.exe -l"*/S" looks for explorer process with /S switch
  47.   pv -r0 -d2000 calc.exe "2>nul" checks every 2 seconds if calc.exe is running
复制代码

[ 本帖最后由 pusofalse 于 2008-10-28 16:06 编辑 ]
心绪平和,眼藏静谧。

TOP

返回列表