Solved

Combine two batch files

Posted on 2015-02-03
6
281 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
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 95

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 23

Expert Comment

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

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

Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now