Solved

Combine two batch files

Posted on 2015-02-03
6
300 Views
Last Modified: 2015-02-03
How can I combine the following two batch files

"C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off

Open in new window

and
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

0
Comment
Question by:Gerhardpet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 40587592
Can you not just merge them into a single file?  The call to the PSQL Backup Agent should fire, and when it comes back, the other two commands should run.  Remember to always give the Backup Agent some time to complete its task -- pulling a large file set out of Continuous Operations mode may take a while, especially if the disk is busy.

If you really want to leave them separate, then you can create a THIRD batch file like this:
    CALL BatchA
    CALL BatchB
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40587600
Agreed, just put the three commands together one after another, unless the first command when it runs returns straight away to the batch file and completes it's work in the background?

Presumably you want to remove the older files using forfiles then run the backup process?

Steve
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 40587607
Batch files execute in sequence and wait for the command run to complete.  If you don't want the batch file to wait, then you use "start"

For example:
"C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

will execute PVBackup.exe and wait for it to complete.  Once completed it will run the first ForFiles command.

If you want pvbackup.exe to run start and then have for files execute nearly instantly after pvbackup starts, you use start, like this:
Start "" "C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Author Comment

by:Gerhardpet
ID: 40587729
So if I combine all of them into one file will each line finish first before the next one starts?
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40587731
The first example will.
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 40587733
Yes, that's what I said - Batch files execute in sequence and wait for the command run to complete.

That said, there is a CHANCE it won't if the pvbackup.exe actually starts another program and exits.  Only way to know for sure is to test.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question