Running two bat files ?


  1. Posts : 24
    windows 7 home premium 64 bit
       #1

    Running two bat files ?


    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:
    @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:
    @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 !


    ..
      My Computer


  2. Posts : 3,487
    Win 7 Pro x64/Win 10 Pro x64 dual boot
       #2

    Use a text editor and copy and paste BAT file 2 onto the end of BAT file 1, and save as a BAT file with a different name. You should be good to go, if they run properly one right after another. Like this:

    Code:
    @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
    
    @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
      My Computer


  3. Posts : 24
    windows 7 home premium 64 bit
    Thread Starter
       #3

    Worked PERFECT! Thank you SO very Much!
      My Computer


  4. Posts : 3,487
    Win 7 Pro x64/Win 10 Pro x64 dual boot
       #4

    You're very welcome. :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:57.
Find Us