Running an .exe file through a batch file and passing parameters
Solution 1
try this, it works with AVI as the main extension, you may change this:
@echo off &setlocal enabledelayedexpansion for %%i in (*.avi) do ( set "line=" for %%j in ("%%~ni.*") do set line=!line! -"%%~j" start "" test_app.exe !line! )
Solution 2
Try this with your avi files. It will just echo the bunch of commands and you can see what it does. The - signs seem a bit odd but I included them with the names.
@echo off
for %%a in (*.avi) do (
echo exe.file "-%%a" "-%%~na.txt"
)
pause
Comments
-
MaxPower almost 2 years
I have an .exe file that takes two parameters when i run it from the command line, as such:
test_app.exe -vid.avi -data.txt
How would i be able to
START
the.exe
file through a batch script and pass it those parameters?If i have multiple
.avi
and.txt
files that i need to pass to the.exe
file throughSTART
, how would i be able to have a variable that goes through all of those files two at a time? (pairing every.avi
with it's correspondant.txt
).Let's assume that every pair of
.avi
and.txt
share the same name but obviously have different extensions.I need to write something like this:
@ECHO OFF START test_app.exe -vid.avi -data.txt pause
But the parameters should be variables that increment every time a pair of parameters are proccessed through the
.exe
so it would loop on all of the files in the CWD.Trying to do this but seems like START does not work that way?
@echo off for %%a in (*.avi) do ( START Tester.exe -%%a -%%~na.txt ) pause
-
MaxPower almost 11 yearsIs the .txt file also added into !line!? It's a bit confusing for me since i barely have any experience with this, sorry.
-
Endoro almost 11 yearsAll files with the same name are on the line, eg. vid.avi, vid.txt, vid.dta. What files do you need at one line?
-
MaxPower almost 11 yearsin every line i need to start the exe and give it two parameters... the avi and txt files.
-
MaxPower almost 11 yearsI need to actually start the exe file with those parameters, i don't understand how echo helps here... sorry if i totally missed the point.
-
foxidrive almost 11 yearsYou haven't supplied an authentic command line - but I supplied the code to launch the exe with the two files. All you need to do is replace the exe filename, and remove the echo, assuming that
"-filename.avi" "-filename.txt"
is what you need to feed the exe file with. The echo was to show you what the code was doing. -
foxidrive almost 11 yearsYour command line looks wrong. The switches aren't normal. MOITester.exe doesn't get a hit in google so I can't help you with what the syntax is.
-
MaxPower almost 11 yearsMOITester is just a random name. I don't understand what you mean by the switches aren't normal. all i'm trying to do is call tester.exe and pass it two arguments at a time. One being .avi and the other being .txt
-
foxidrive almost 11 years
test_app.exe -vid.avi -data.txt
Does that work for you? It is the information you provided, and if it doesn't work then the code I provided isn't going to work either. Show us what works for you with your executable. -
Endoro almost 11 yearsAnd where do the parameters come from?
-
MaxPower almost 11 yearsfrom the current directory. It has a bunch of avi's and txt's. every pair of avi+txt share the same name
-
Endoro almost 11 years@MaxPower yes, this does my code: search for an AVI and collect all files with the same name & put it at the line.
-
MaxPower almost 11 yearsthis "test_app.exe -vid.avi -data.txt" works through the command line. But through a batch file i need to use START i think... and that is what does not work. I can only do it one by one using hte command line. What i am trying to do is automate the proccess to have it run on all files in the current directory.