1.

Solve : Running two bat files ??

Answer»

I have a outlook backup program that backs up all the mail and offers a way to enter a POST Backup CMD

The program runs great and if I add a script (bat file) in the post back up CMD area, it will also run perfectly separately


BUT


I have two (2) scripts (.bat files) I would like to run, ONE after the other,,, but NOT sure how to join them..

I included the 2 scripts here if someone can help me?

bat file one: (backup_additional_settings.bat)

Code: [SELECT]@ECHO OFF
rem set backup folder here
pushd \\FILESERVER\OUTLOOK\CD-OPTI9020

setlocal EnableDelayedExpansion

rem backup signatures
copy "%APPDATA%\Microsoft\Signatures\*" *

rem backup registry settings
rem uncomment for outlook 2010
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

rem uncomment for outlook 2013
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles"

rem uncomment for outlook 2016
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles"



endlocal


and here is the second bat file: (keep_n_backups.bat)

Code: [Select]@echo off
setlocal enableextensions enabledelayedexpansion

rem set max no of backups to keep and backup folder
set MAX_BACKUP=5
pushd \\FILESERVER\OUTLOOK\CD-OPTI9020


set rev=0

rem read LAST revision no
if exist revision.txt (
for /f "delims=" %%a in (revision.txt) do (
set rev=%%a
)
)
Set /A rev=!rev!+1
Set /A rev=!rev! %% !MAX_BACKUP!

rem find pst-file and rename
FOR /F "delims=" %%I IN ('DIR *.pst *.ost /B') DO (
set x=%%I
if exist "!x:~0,-4!_!rev!.bak" del "!x:~0,-4!_!rev!.bak"
ren "!x!" "!x:~0,-4!_!rev!.bak"
)

echo !rev! > revision.txt


endlocal



any help would be GREAT !

Never mind I figured it out..Thanks

Excellent.Your first batch file literally only has two lines of relevant code. How hard could that be to put into the second batch file.

Your second batch file you have a few INSTANCES when you are using delayed expansion when you don't even need to use it.Good you figured it out, note that there are two ways you can do this

starting the second script right before exit

@echo off
echo file1.bat
pause
start file2.bat
exit

or calling the second script

@echo off
echo file1.bat
pause
CALL file2.bat
pause
exit



Discussion

No Comment Found