Eric
Eric

Reputation: 941

Batch file to "call" a batch file with a pause or "wait"

I have a batch file that "calls" another batch file, but I need to "wait" before it proceeds. How can I make this happen?

@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
)

I have tried start /wait instead of call but it doesn't seem to work.

Upvotes: 0

Views: 136

Answers (1)

Magoo
Magoo

Reputation: 79982

Insert a

timeout /t n >nul

instruction before the call, where n is the number of seconds to wait.


Delayed Expansion strikes again!

Easy solution:

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

Note the CALL and the doubling of %. This executes the echo in a subprocedure, passing %DATE% hence reporting the current date/time.

See many articles on delayed expansion by using the search facility.

Upvotes: 1

Related Questions