Skip to main content

Wait for a .bat file to complete before starting a backup

Thread needs solution

I am setting up the options for a backup.  Under the Advanced tab, I am including a "pre-command" that is a .bat file:
C:/Users/art/Desktop/Mount-M.bat
And I indicate: "Do not perform operations until the command's execution is complete."
The .bat file mounts the external drive for the backup.  Yet, Acronis does not wait for the .bat file to complete.  So, it sends an error email, then tries a second time.  The second time, it succeeds (because enough time has elapsed for the drive to get mounted). 

How do I get Acronis to wait for the .bat file to complete?

 

0 Users found this helpful

Art, are you including any delays in your bat file to allow for Windows actually complete the mount of the external drive?

If not, then add a timeout line before exiting from the BAT file as example below:

timeout /t 60

will give a delay of 60 seconds.

An alternative would be to test within the BAT file whether the drive is mounted:

echo off
set usbhdd="S:"
set loopcount=5
if not exist %usbhdd% goto loop

:exitloop
if not exist %usbhdd% goto nodrive
dir %usbhdd%
echo "Drive found!"
exit /b 0

:nodrive
echo "Drive not found!"
exit /b 1

:loop
set /a loopcount=loopcount-1
if %loopcount%==0 goto exitloop
dir %usbhdd%
timeout /t 5
goto loop