Running .exe file through batch file and transfer options

I have a .exe file that takes two parameters when I run it from the command line, as such:

test_app.exe -vid.avi -data.txt 

How can I START .exe file through a batch script package and pass these parameters to it?

If I have several .avi and .txt files that I need to transfer to the .exe via START , how can I have a variable that goes through all these files, two for a while? (pairing each .avi with it corresponds to .txt ).

Suppose that each .avi and .txt pair has the same name, but obviously has different extensions.

I need to write something like this:

 @ECHO OFF START test_app.exe -vid.avi -data.txt pause 

But the parameters must be variables that increase every time a pair of parameters is processed through .exe , so it will cycle through all the files in CWD.

Trying to do this, but does START seem to not work that way?

 @echo off for %%a in (*.avi) do ( START Tester.exe -%%a -%%~na.txt ) pause 
+4
source share
2 answers

try this, it works with AVI as the main extension, you can 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!
 )
+3
source

Try this with your avi files. He will simply repeat a bunch of commands, and you will see what he does. Signs - seem a little strange, but I included them with names.

 @echo off for %%a in (*.avi) do ( echo exe.file "-%%a" "-%%~na.txt" ) pause 
+2
source

Source: https://habr.com/ru/post/1485762/


All Articles