I have a script which will write a file (currently C:\test.txt) of processes (it checks for processes from a pre-defined list).
I then run some other code (not important what gets done here, but part of this is to end these processes).
My problem is, at this point in my script, I need to be able to relaunch the processes that were terminated but load them with the cmd parameters they were runnign with previously.
The test.txt file will look something like this:
"C:\folder1\folder2\folder3\application2.exe" param1 param2
"C:\folder1\folder2\folder3\application4.exe" param1 param2 param3 param4
I used a for loop to take the lines from the file and try to run them;
for /f "usebackq tokens=1,* delims= " %%C in (C:\test.txt) do (
This woks fine, except that the script waits for the first process to complete (i.e. terminate again), before loading the next one, and these processes will not end!
I tried to use
start %%C %%D
but I loads a new CMD window with the file path, then tries to run the file with the name from %D
start %%C %%C %%D
does seem to work, but I've no idea why, and I'm sure that its not the right way to do this.
Can anyone explain why this works, and the others do not, and if there is a proper way to do this??
The first parameter after start command within quotes is considered as 'Window Title'. Then followed by command and the parameters.
start %%C %%D
does not work as %%C which is within quotes is considered window title and tries to run %%D command.
This should also work:
start "" %%C %%D
Why can't I start programs in the command line without /d? (Windows 7x64)