• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 547
  • Last Modified:

Multiple .bat command in one script

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
sunilbains
Asked:
sunilbains
  • 4
  • 3
1 Solution
 
Steve KnightIT ConsultancyCommented:
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
 
sunilbainsAuthor Commented:
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
 
Steve KnightIT ConsultancyCommented:
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.

 
sunilbainsAuthor Commented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
sunilbainsAuthor Commented:
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
 
Steve KnightIT ConsultancyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now