|
Answer» I have searched through the DOS forum to try and find an answer. I am trying to run a command line program from a batch file, including all inputs, multiple times. I have an Excel VBA sub that will create as many batch files as I need and fill them with the inputs, however what I am running into is that the program I call needs to have the command window it is in close before it is run again (outputs a few files at the close). So I have gotten my batch files to open a new command window, however the commands are still run in the original command window. I have also tried calling batch files that would open a new command window, but ran into the same problem.
Is there a way to open a new command window and execute the program and then close the new command window so that control then returns to the original command window so that it can do it all over again. I have pasted the basics of what I do have below. The variables X_ , Y_ ACTUALLY have numeric values input in by VBA prior to running.
start cmd Prog X_1 Y_1 mkdir c:\newfolder_output\1 %CR% move c:\outputs.* c:\newfolder_output\1 %CR% exit %CR%
start cmd Prog X_2 Y_2 mkdir c:\newfolder_output\2 %CR% move c:\outputs.* c:\newfolder_output\2 %CR% exit %CR%
My reason is that the program (Prog) does not change the output files names each time it runs, so I want to run it with new inputs and then move the outputs to a new folder and then run it again, but I do have to close the command window that it runs in each time. When I do the above code, it tries to run it all in the same command window and I get two blank command windows. Any ideas on what to do? Thanks StanWhat does the variable %CR% do? Sorry, that is an environmental variable I set that performs a "carriage return" each time it is called so it is a way of hitting the enter key from the batch file. Not SURE if it is needed, but figured that it couldn't hurt. Worst case is that I end up with a few blank lines.What does it consist of? I just created a variable using regedit by pressing cntrl-alt-ent I believe in the value field. It's symbol is a square. I have only been programming for about 2 months so I am pretty new to a lot of things. It was something I found online to help with a PREVIOUS programming issue so I was attempting to use it here in order to execute each line. I am not sure if a batch file does that anyways, but if so then it is one less thing to have to put in.You do not need it and it is probably not helping. Each line of a batch file is executed in TURN anyway.
What is the MOVE command supposed to be doing?
the move command is the dos move command that is looking for the output files from the program named Prog and then moving them to a folder that is created for that instance of running Prog.exe. This makes it possible to run Prog.exe 300 times without having to manually move the outputs each time (otherwise they are written over each time) or having to manually run Prog.exe 300 times. I need to close the command window after each execution of Prog.exe because some .dat files are written and are called for the next run. It is a painful way to run a program, but I haven't found a better one that makes it possible to run it like this.Try this
start /wait "" "Prog" X_1 Y_1 mkdir c:\newfolder_output\1 move c:\outputs\*.* c:\newfolder_output\1
start /wait "" "Prog" X_2 Y_2 mkdir c:\newfolder_output\2 move c:\outputs\*.* c:\newfolder_output\2
Ok, thanks for the help, by using the /wait command I have it working now. Also I am using variables to call up another batch file to run the variables from the first (just cuts down the file size and still lets me move the output files before it starts the next ITERATION). Thanks again for the help. I have 3 weeks left on this project and now it looks like I will get it done with some time to spare.
|