标题: [日期时间] 求批处理代码显示实时计算时间 [打印本页]
作者: meiszp 时间: 2024-5-27 16:39 标题: 求批处理代码显示实时计算时间
bat依次调用ab.exe计算1.txt,cd.exe 计算2.txt
现在的bat- ab.exe 1.txt
- cd.exe 2.txt
复制代码
求代码实时显示ab.exe计算1.txt的用时,cd.exe 计算2.txt的用时
希望的bat- ab.ext 1.txt
- 已运行xx小时xx分xx秒
- cd.exe 2.txt
- 已运行xx小时xx分xx秒
复制代码
作者: Five66 时间: 2024-5-27 20:24
- @echo off
- set "@block={$t=get-date;($t-[datetime][int64]$args[0]).tostring()}"
-
- for /f %%i in ('powershell -c "(get-date).ticks"') do set @time=%%i
- ab.exe 1.txt
- for /f %%i in ('powershell -c "%@block%.invoke(%@time%)"') do echo 已运行 %%i
-
- for /f %%i in ('powershell -c "(get-date).ticks"') do set @time=%%i
- cd.exe 2.txt
- for /f %%i in ('powershell -c "%@block%.invoke(%@time%)"') do echo 已运行 %%i
复制代码
作者: wom087 时间: 2024-5-28 08:54
供参考
echo.&echo ===== %folder% 恢复 Printers.请等待 =====
set time_begin=%time:~0,-3%
start /wait /min cmd.exe /c C:\Windows\System32\spool\tools\Printbrm.exe -R -F %folder%
set time_end=%time:~0,-3%
call :_difftime %time_begin% %time_end%
echo Printers 恢复完成. 用时: %hour_% 时 %munite_% 分 %second_% 秒
pause >nul
goto :BackupTools
:_difftime <time_begin> <time_end>
for /f "tokens=1,2,3 delims=:" %%i in ("%time_begin%") do (
set /a hour_b=%%i
set /a munite_b=%%j
set /a second_b=%%k
)
for /f "tokens=1,2,3 delims=:" %%i in ("%time_end%") do (
set /a hour_a=%%i
set /a munite_a=%%j
set /a second_a=%%k
)
if %second_a% lss %second_b% (
set /a munite_a=%munite_a%-1
set /a second_a=%second_a%+60
)
set /a second_=%second_a%-%second_b%
if %munite_a% lss %munite_b% (
set /a hour_a=%hour_a%-1
set /a munite_a=%munite_a%+60
)
set /a munite_=%munite_a%-%munite_b%
if %hour_a% lss %hour_b% (
set /a hour_a=%hour_a%+24
)
set /a hour_=%hour_a%-%hour_b%
Goto :eof
作者: hnfeng 时间: 2024-5-31 12:52
本帖最后由 hnfeng 于 2024-5-31 13:01 编辑
要实时显示,是不是这样的
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |