Computer Hope
Microsoft => Microsoft DOS => Topic started by: kepler on June 03, 2017, 07:16:02 AM
-
Good morning
I'm making a batch file for windows, but I want it to receive several parameters and output the result to a file.
Is this the right way to write the batch file?
%1 %2 %3 %4 %5 %6 %7 %8 %9 > results.txt
where %1 is the exe? Doesn't seem to work very well when integrated within othe apps...
Regards
Kepler
-
Generally speaking, you have the right idea. You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output. There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned. Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.
Can you give more specific examples of what you are trying to do?
-
Can you give more specific examples of what you are trying to do?
++1
-
shift
-
Generally speaking, you have the right idea. You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output. There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned. Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.
Can you give more specific examples of what you are trying to do?
Good day
I'm sorry for the late reply. I wasn't able to check my email yesterday...
The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.
So, for instance, I would call;
mybatch.bat myexe.exe param1 param2
would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):
myexe.exe param1 param2 > results.txt
The exe would be a "parameter" to the batch, but to run.
Kind regards,
Kepler
-
The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.
So, for instance, I would call;
mybatch.bat myexe.exe param1 param2
would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):
myexe.exe param1 param2 > results.txt
That might work, provided the exe was written to accept command line parameters, and it writes text output to the console (to STDOUT if you want to get technical.) A quick question: why don't you just try it?
-
Hi
No, it wasn't working.... because the bat file was in utf8!!!... Jesus... I'm sorry for the trouble.
Have a nice weekend.
Kepler