批量文件到"调用"暂停的批处理文件或"等待"

时间:2018-02-21 19:27:56

标签: windows batch-file cmd

我有一个批处理文件"调用"另一个批处理文件,但我需要"等待"在它继续之前。我怎样才能做到这一点?

@echo off
if exist "C:\Program Files\Dassault Systemes\B25\DSUninstall.bat" (
echo Catia PLM-ex V5-6R2015 needs to be removed %DATE% %TIME% >>"C:\catiaV5-6R2015.txt"
call "C:\Program Files\Dassault Systemes\B25\DSUninstall.bat"
echo Catia PLM-ex V5-6R2015 has been removed %DATE% %TIME% >>"C:\catiaV5-6R2015.txt"
exit
) else (
echo Catia PLM-ex V5-6R2015 is not installed. %DATE% %TIME% >>"C:\catiaV5-6R2015.txt"
exit
)

我尝试过start /wait代替call,但它似乎无法发挥作用。

1 个答案:

答案 0 :(得分:1)

插入

timeout /t n >nul
通话前的

指令,其中n是等待的秒数。

Delayed Expansion再次罢工!

简易解决方案:

CALL echo Catia PLM-ex V5-6R2015 has been removed %%DATE%% %%TIME%% >>"C:\catiaV5-6R2015.txt"

请注意CALL%的加倍。这会在子过程中执行echo,传递%DATE%,从而报告当前日期/时间。

使用delayed expansion工具查看search上的许多文章。