Solved how do i create a batch that can run an executable w/ parms

January 31, 2019 at 05:27:37
Specs: Windows 10
I have a directory with multiple xml files in it. I need to have a batch file go to this directory and get an xml file. it runs an executable with the filename being passed to it. The executable returns an error code, then based on the returned code, either delete the file if successful (0), error 1-7 - copy it to "BAD" directory, and codes 8 and 9 leave the file, they will be tried later.

Right now, i just have a single file that is always named the same and in a different directory. i do the copying and deleting of the files in a proprietary scripting language outside of the batch file.

Any help would be much appreciated.

Here is my current batch file.

#
path=c:\14828\TDM
cd c:\14828\TDM echo

UploadXmlTestResults.exe C:\14828\TDM\TDM_XML_FILE.xml
exit %errorlevel%


See More: how do i create a batch that can run an executable w/ parms

Reply ↓  Report •

#1
January 31, 2019 at 06:49:16
✔ Best Answer
run the .bat file like this from a shortcut:

FULLPATH\whatever.bat c:\14828\TDM c:\14828\TDM C:\14828\TDM\TDM_XML_FILE.xml


@echo off&setlocal
::thisbatname.bat variable1 variable2 variable3
set "var1=%1"
set "var2=%2"
set "var3=%3"
path=%var1%
cd %var2% echo
UploadXmlTestResults.exe %var3%
exit/b

i5-6600K[delid]@4.7GHz/4.4GHz cache/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz

message edited by hidde663


Reply ↓  Report •

#2
January 31, 2019 at 08:06:27
Thank you!! :)

I'm a newbie...

Do the variable just go in order that they are passed in?
var1 is the path
var2 is the directory
var3 is the file name



Reply ↓  Report •

#3
January 31, 2019 at 08:42:10
that is indeed correct

edit:

i've added setlocal just so you won't overwrite the actual %PATH%variable used by windows ;)

i5-6600K[delid]@4.7GHz/4.4GHz cache/@1.395v LLC=6 | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | MSI Armor RX 570 4GB@1410Mhz core@1.2v/1920MHz

message edited by hidde663


Reply ↓  Report •
Related Solutions


Ask Question