Using START /wait with MozBackup batch scripts

0

1

OS: Windows 7 64-bit

I have three batch files.

  1. FirefoxBackup.bat
  2. ThunderbirdBackup.bat
  3. Firefox_Thunderbird_Backup.bat

The script inside Firefox_Thunderbird_Backup.bat is shown below:

@echo off
@echo Welcome to Firefox and Thunderbird Automated Backup!
CALL "D:\Scripts\FirefoxBackup.bat"
CALL "D:\Scripts\ThunderbirdBackup.bat"

The script inside FirefoxBackup.bat file is very similar to ThunderbirdBackup.bat. Kindly see Firefox backup batch script below:

@echo off
@echo Firefox backup will begin shortly!

echo.
@echo Deleting old Firefox backup file(s)...
@echo off
DEL /F "D:\Mozilla Products Backups\Firefox*.pcv"
TIMEOUT /T 2 /NOBREAK

echo.
@echo off
@echo Firefox is quitting...
TIMEOUT /T 2 /NOBREAK

@echo off
@echo off tasklist /nh /fi "imagename eq firefox.exe" | find /i "firefox.exe" >nul && ( taskkill /f /im firefox.exe /T )
TIMEOUT /T 3 /NOBREAK

echo.
@echo Firefox backup is in progress!
START "" "C:\Program Files (x86)\MozBackup\MozBackup.exe" "D:\Scripts\Default.firefoxprofile"
TIMEOUT /T 15 /NOBREAK

echo.
@echo Firefox backup successful!
echo.

@echo Firefox has re-launched.
echo.
START "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"

The part I'm interested in is:

START "" "C:\Program Files\MozBackup\MozBackup.exe" "D:\Scripts\Default.firefoxprofile"
TIMEOUT /T 15 /NOBREAK

Explanation on the above code snippet:

MozBackup.exe is started along with a parameter. This parameter is the Default.firefoxprofilefile which MozBackup understands, and can be manually edited as per the instructions here.

Intentions:

I'd like to get rid of the manual waiting time (15s) and make use of START /wait. This way, Firefox re-launches only after Mozbackup finishes executing. I am not sure how to go about this considering there are already 3 parameters, namely "", C:\Program Files\MozBackup\MozBackup.exe, and D:\Default.firefoxprofile. Is it possible to achieve that at all anyway?

Thank you!

Ugo

Posted 2014-01-26T18:18:45.580

Reputation: 249

What makes you think you can't use more than 3 parameters with Start? – Ƭᴇcʜιᴇ007 – 2014-01-26T18:21:07.300

I tried. It didn't work and I deduced that maybe I'm passing too many parameters. – Ugo – 2014-01-26T18:22:18.193

Answers

0

The answer was much simpler than I expected. I just needed to use the /W switch. I noticed that the /WAIT switch does not work.

Here's the solution:

START /W "" "C:\Program Files (x86)\MozBackup\MozBackup.exe" "D:\Scripts\Default.firefoxprofile"
START /W /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"

What happens now is that Firefox will re-launch only after MozBackup has finished executing. I will also apply this to Thunderbird's backup script. Thank you for reading and I hope this backup script is useful to someone in the future :)

Reference

Ugo

Posted 2014-01-26T18:18:45.580

Reputation: 249