windows 7 - Using START /wait with MozBackup batch scripts
2014-04
OS: Windows 7 64-bit
I have three batch files.
- FirefoxBackup.bat
- ThunderbirdBackup.bat
- 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.firefoxprofile
file 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!
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 :)
I've a simple batch script npp.bat to open a file in Notepad++
"C:\Program Files\(x86)\Notepad++\notepad++.exe" %1
Notepad++ launches with the file when I run npp <file_name>>
but the command window waits for the application to exit. I don't want it to wait.
Use start
instead:
start "" "command here"
Edit: Do not miss the first pair of empty quotes, this is the title of the process/window.
start <title> <command> <parameters>
See start /?
for further details.
I wanted to be able to do "npp file.txt" on the command prompt and be able to edit files using Notepad++. For this, I created a new folder, added it to Windows PATH, and created a file there called npp.bat with the following content:
@echo off
start "" "C:\Program Files\Notepad++\notepad++.exe" %1
Very useful when I'm working on the console and need to edit a file.
@Bobby method should work, If you directly calls the batch script ( double click ), the method will open a new command window. Instead use the following,
@echo off
start "C:\Program Files\Notepad++\notepad++.exe" blah.txt
cls
exit
If you replace blah.txt
with %1
, then you should pass the argument when you call the batch file.