?
Solved

Multiple .bat command in one script

Posted on 2008-11-10
7
Medium Priority
?
534 Views
Last Modified: 2012-06-27
Hi all,
 Iam trying to combine 4 scripts into one .bat file .
Final.bat file looks like below.

@echo off

IF "%1%"=="" GOTo USAGE
IF "%2%"=="" GOTo USAGE
IF "%3%"=="" GOTo USAGE
IF "%4%"=="" GOTo USAGE


C:\test\FtpDownload.bat %1 %2 %3
C:\test\UnzippingDrop.bat %3 %4 %3
C:\test\deployment\install_fixconfigs.cmd dev2
C:\test\CopyDropDev2.bat %3\web
goto END

:USAGE
ECHO.
echo Parameter "filename filedate droppath dropname extractpath website " need to be passed in a sequence.
ECHO.

:END

But when i run final.bat with 4 parameters.
its only able to download files and then show the prompt. It doesnot go to next script.

can somebody help.
0
Comment
Question by:sunilbains
  • 4
  • 3
7 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 22925330
You need to use CALL command to run another script in this case as otherwise you run another batch file it nevers returns to the first, i.e.

call c:\test\ftpdownload.bat %1 %2 %3

hth

Steve
0
 

Author Comment

by:sunilbains
ID: 22929497
I put call statement as below.
call C:\test\FtpDownload.bat %1 %2 %3
call C:\test\UnzippingDrop.bat %3 %4 %3
call C:\test\deployment\install_fixconfigs.cmd dev2


but its not running 3rd call statment.
After second (which is to unzip file), it returns prompt.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 22929935
Ok then I imagine in the ftpdownload.bat you have another batch file being called, add a CALL to that too or post the file here if not sure

Steve
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:sunilbains
ID: 22931616
Hi Steve,
 call C:\test\FtpDownload.bat %1 %2 %3
call C:\test\UnzippingDrop.bat %3 %4 %3
call C:\test\deployment\install_fixconfigs.cmd dev2

First to calls are runing fine one fater another. but ater second call finishes, it gives prompt .
Second script , just unzip files using 7za.exe.  But after  in unzips, its shows prompt ant doesnot start call to third script.

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 22931679
OK. I meant the second script but as long as it doesn't call another batch file it should continue.  You COULD always run them instead as

START "Downloading..." /WAIT /b C:\test\FtpDownload.bat %1 %2 %3
START "Unzipping..." /WAIT /b C:\test\UnzippingDrop.bat %3 %4 %3
START "Install..." /WAIT /b C:\test\deployment\install_fixconfigs.cmd dev2

or just put them all in together in one batch. I assume you have the filenames right, i.e. the last one you show as a .CMD file and the others .BAT.  Would suggest you make them all .CMD unless there is a reason not to.

Steve
0
 

Author Comment

by:sunilbains
ID: 22931861
Hi Steve,
 I have put them in one bat file called final.bat file
Contents of final.bat is
@echo off

IF "%1%"=="" GOTo USAGE
IF "%2%"=="" GOTo USAGE
IF "%3%"=="" GOTo USAGE
IF "%4%"=="" GOTo USAGE


START "Downloading ..." /WAIT /b  C:\test\FtpDownload.bat %1 %2 %3
START "Unzipping.." /WAIT /b  C:\test\UnzippingDrop.bat %3 %4 %3
START "INSTALL.." /WAIT /b  C:\test\deployment\install_fixconfigs.cmd dev2
goto END

:USAGE
ECHO.
echo Parameter "filename filedate droppath dropname extractpath website " need to be passed in a sequence.
ECHO.

:END

But itsnot running in sequence..

0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 22932009
It seems to work for me but I used all .cmd instead of .bat.  Call the main one final.cmd too?  

Might also need to remove the /b which saves the extra cmd.exe windows popping up but sometimes stops it detecting the program has finished.

Steve
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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