I have multiple batch files. Each batch file opens an exe file and run a command. The command compiles the results in csv format. This all works like heaven.
I am trying to create a master batch which could run each of the batch file one by one.
The individual batch file names are as 1.bat, 2.bat . . . .32.bat
I tried,
Call 1.bat
Call 2.bat
.
.
.
Call 32.bat
but it is only running the first command...
I also tried without call, same result.
I am using the following code in each batch file:
Start /D "C:\test 2\" CSC.exe "1.lq"
Start /D "C:\test 2\" CSC.exe "2.lq"
and so on
Can anyone help me crack this?
All I want My master bat to run first batch, on completion run second and so on so forth.
Hope it makes sense.
I really appreciate your help on this guys.
Shei
Try like this:-
START /WAIT batch1.bat
START /WAIT batch2.bat
Related
Am trying to create a batch file, that would launch multiple programs. But unfortunately, things don't seem to work.
Kindly, find below my requirement:
Open InfluxDB server
Launch Grafana application.
Commands used in the batch:
#echo off
cd "C:\Users\C51539A\Downloads\influxdb-1.5.2-1"
Start.cmd
timeout 5
cd "C:\Users\C51539A\Downloads\grafana-5.1.3\bin"
grafana-server.exe
The above script, launches InfluxDB. But doesn't moves further.
Could you please suggest me, on how to proceed?
You need to use the call keyword to have control returned to the caller after invoking another batch script:
#echo off
cd "C:\Users\C51539A\Downloads\influxdb-1.5.2-1"
call start.cmd
...
Should start.cmd run InfluxDB synchronously (i.e. not in the background) you need to launch it in a separate window:
#echo off
cd "C:\Users\C51539A\Downloads\influxdb-1.5.2-1"
start "InfluxDB" cmd /c start.cmd
...
#echo off
cd "C:\Users\C51539A\Downloads\influxdb-1.5.2-1"
start InfluxDB
ping -n 6 127.0.0.1 > nul
cd "C:\Users\C51539A\Downloads\grafana-5.1.3\bin"
start grafana-server
Edit the "start InfluxDB" and "start grafana-server" to be the correct exe names, without .exe
I have a Main folder which contains 3 subfolders. I want to make a batch file in my main folder that will execute the batch files in 3 subfolders at the same time. I want to do this without using a for loop.
Just to get a clear idea here is the structure:
MainFolder
-abc.bat
Subfolder1
-a.bat
Subfolder2
-b.bat
Subfolder3
-c.bat
The batch file in Mainfolder (abc.bat) should be able to execute the 3 batch files in subfolders at the same time.
Try the following command in abc.bat and let me know if this is what you want:
set CALL_PATH=%~dp0
start call %CALL_PATH%\Subfolder1\a.bat
start call %CALL_PATH%\Subfolder2\b.bat
start call %CALL_PATH%\Subfolder3\c.bat
After reading your comment, I think your problem is to run in the same screen while using start. For this you can use the /I flag
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
like so:
set CALL_PATH=%~dp0
start /I call %CALL_PATH%\Subfolder1\a.bat
start /I call %CALL_PATH%\Subfolder2\b.bat
start /I call %CALL_PATH%\Subfolder3\c.bat
If this does not help, please read the help for the start command using:
start /?
I need a batch file which will do the following:
1. Open CMD and navigate to a location C:/Users/...../program.exe
2. Run the program.exe with an additional command to point it to a config file:
e.g. "program.exe C:/Users/..../configFile.bgi"
How can I do this?
I tried this but with no luck:
start "C:\Users\Ben\Desktop\BGInfo\bginfo.exe C:\Users\Ben\Desktop\BGInfo\dc_bginfo.bgi"
pause
Update
I've used the solution provided by Ganesh (below) and came up with this:
cd C:\Users\Ben\Desktop\BGInfo\
bginfo.exe C:\Users\Ben\Desktop\BGInfo\dc_bginfo.bgi
I've tested it on a local machine (changing the directories) but on the server (with the directory above) it does not work...
The folder directory with batch file:
The error
in batch file abc.bat
cd c:\user\ben_dchost\documents\
executible.exe -flag1 -flag2 -flag3
I am assuming that your executible.exe is present in c:\user\ben_dchost\documents\
I am also assuming that the parameters it takes are -flag1 -flag2 -flag3
Edited:
For the command you say you want to execute, do:
cd C:\Users\Ben\Desktop\BGInfo\
bginfo.exe dc_bginfo.bgi
pause
Hope this helps
You can use
start "" "%USERPROFILE%\Desktop\BGInfo\bginfo.exe" "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi"
or
start "" /D "%USERPROFILE%\Desktop\BGInfo" bginfo.exe dc_bginfo.bgi
or
"%USERPROFILE%\Desktop\BGInfo\bginfo.exe" "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi"
or
cd /D "%USERPROFILE%\Desktop\BGInfo"
bginfo.exe dc_bginfo.bgi
Help on commands start and cd is output by executing in a command prompt window help start or start /? and help cd or cd /?.
But I do not understand why you need a batch file at all for starting the application with the additional parameter. Create a shortcut (*.lnk) on your desktop for this application. Then right click on the shortcut, left click on Properties and append after a space character "%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi" as parameter.
Found another solution for the same. It will be more helpful.
START C:\"Program Files (x86)"\Test\"Test Automation"\finger.exe ConfigFile="C:\Users\PCName\Desktop\Automation\Documents\Validation_ZoneWise_Default.finger.Config"
finger.exe is a parent program that is calling config solution.
Note: if your path folder name consists of spaces, then do not forget to add "".
.
I am trying to create a batch file to avoid a repetitive tasks,
but the commands after the command "dx --dex --output=classes.dex FINAL.jar" which i execute to create a .dex file from .jar file do not execute. The commands before "dx --dex --output=classes.dex FINAL.jar" command executes serially well, this command also executes successfully , it does not give me any error.
But after successful execution of this command command prompt exits automatically,and rest commands do not execute.
Following is my AUTO.bat file:
del Freedom_Plus_Img_Cust.apk_signed.apk
del classes.dex
dx --dex --output=classes.dex FINAL.jar
ping 1.1.1.1 -n 1 -w 30000
move /Y XXXX.apk XXXX.zip
7z d XXXX.zip classes.dex
7z a XXXX.zip classes.dex
move /Y XXXX.zip XXXX.apk
java -jar signapk.jar certificate.pem key.pk8 XXXX.apk
setlocal EnableDelayedExpansion
#ECHO off
set /p pathName=Enter The Value:
#echo %pathName%
So please can anyone tell me why this could happen.Any solution to this could appreaciable.
Thanx in advance .
Note: I am using Windows XP . .
I repeat the right answer from MC ND to remove this already answered question from the list of unanswered questions.
Command dx is not a command, nor is it a console application. It is another batch file.
A batch file must be executed from within a batch file using command CALL or cmd.exe continues batch execution on the other executed batch file without returning back to initial batch file.
For details about command CALL execute in a command prompt window call /?
This behavior can be verified easily with 2 batch files.
Batch file 1 with name test1.bat:
#echo off
test2.bat
echo End of test1.bat
pause
Batch file 2 with name test2.bat:
echo End of test2.bat
Pause
Execution of test1.bat results in output:
End of test2.bat
Press any key to continue . . .
The lines after start of test2.bat are not executed anymore by cmd.exe.
With changing in test1.bat the second line to call test2.bat the output on execution of test1.bat changes to:
End of test2.bat
Press any key to continue . . .
End of test1.bat
Press any key to continue . . .
Hint: In batch files it is advisable to call other files (EXE, COM, BAT, CMD, ...) always with their file extension. This makes the execution of the batch file a little bit faster as Windows do not need to search for name.* in current directory and in all directories of environment variable PATH to find the file which should be executed. It is also advisable to call other files with full path if the batch file must not work with paths relative to current working directory to avoid a dependency on directories in PATH.
I wrote a batch file, which has 3 .bat file running in background. I have another batch file which has 3 .bat file, which is used to stop those .bat file which ran in first batch file. All this is working fine, but after stopping those .bat files, first batch file's command window is not closing. I gave 'exit' to both the batch file which I wrote.
Please help me in this.
You could try starting the other batch files with
CMD /C
alternatively when they are supposed to close, you could try closing them by name directly from the other batch file:
taskkill /F /IM batchname.bat
Are you using
call batchfile.bat
to run the batchfiles? If not, the flow will be unexpected.
if you could convert it to .exe, with Bat-To-Exe-Converter, you could use:
tskill [program]
Like if you want to close a batch file which is converted called 'helloworld.exe':
tskill helloworld
What you also could use,
is:
tskill cmd
And do this a few times. It will close 1 commdandprompt/time.
I do a delayed close with some of my batch scripts this way:
FOR /l %%a in (30,-1,1) do (TITLE %TITLE% -- Closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL)
EXIT /B 0