我正在使用批处理文件(* .bat)来运行多个程序。
每一行(例如myexe.exe)可能需要很长时间,所以我想要
我该怎么办?
请索取代码示例。
谢谢:)
答案 0 :(得分:0)
这就是我创造的:
@echo off
setlocal
set "executable=notepad.exe"
set "work_dir=."
for /f "skip=5 tokens=* delims=" %%# in ('wmic process call create "%executable%"^,"%work_dir%"') do (
for /f "tokens=1,2 delims=;= " %%a in ("%%#") do (
rem --In the part "%%a" equ " ProcessID" the blank before the ProcessID is a single tab
rem --Some (browser/online)editors could alert it to spaces!
if not defined PID if "%%a" equ " ProcessId" set "PID=%%b"
)
)
if not defined PID echo Failed to start the process && exit /b 3
set s_time=%time%
set "_0=/"
set "_1=-"
set "_2=\"
set "_3=|"
set counter=0
set "line=."
:loop
echo executing %executable% [%s_time%]
set /a counter=counter+1
set /a mod=counter%%4
if %mod% equ 0 set line=%line%.
qprocess %PID% >nul 2>&1 && (
setlocal ENABLEDELAYEDEXPANSION
echo %line%!_%mod%!
pathping 127.0.0.1 -n -q 1 -p 300 >nul
cls
endlocal
goto :loop
) || (
echo execution of %executable% finished [%time%]
)
endlocal
目前清除屏幕是强制性的,但可能会为您完成这项工作?此外,WMIC
不适用于WinXP家庭版。