Page 1 of 1

calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 09:48
by signalMTB
I am trying to kickoff multiple sessions of a program called SaTScan.This SaTScan program has an exe file which can be called from the DOS prompt, and you then feed it a .prm file and it runs off of that. So in simple DOS terms, it would look something like:

"cd c:\Program Files\SaTScan"
"SaTScanBatch.exe C:\temp\parameter_file_1.prm"

How can I write a .bat file so that I can kick off multiple sessions of the program at one time, such that I can run many parameter files at once across separate CMDs rather than running it one by one. For example:

"cd c:\Program Files\SaTScan"
"SaTScanBatch.exe C:\temp\parameter_file_1.prm"

"cd c:\Program Files\SaTScan"
"SaTScanBatch.exe C:\temp\parameter_file_2.prm"

"cd c:\Program Files\SaTScan"
"SaTScanBatch.exe C:\temp\parameter_file_3.prm"

"cd c:\Program Files\SaTScan"
"SaTScanBatch.exe C:\temp\parameter_file_4.prm"

etc.

TIA

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 10:17
by dbenham
Check out the START command (type START /? to get help)

Dave Benham

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 10:31
by signalMTB
dbenham wrote:Check out the START command (type START /? to get help)

Dave Benham


I've tried several iterations of that, and using cmd and a /k command, all of which I know little about in DOS. The only think I was able to do was successfully get the CMD window to open and got to the directory I need. Can't actually get it to run though.

More help is greatly appreciated.

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 11:23
by Squashman
Instead of just saying you tried this or that you should actually post the code you tried and then explain what happened when you tried it and if there was any error messages.

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 11:42
by signalMTB
Squashman wrote:Instead of just saying you tried this or that you should actually post the code you tried and then explain what happened when you tried it and if there was any error messages.


I tried this, but it only brings up the CMD window and it is at the correct directory. but it doesnt launch the exe

@echo off
cmd /k "cd c:\Program Files\SaTScan"
start "" "SaTScanBatch.exe"
cmd /k "C:\temp\params998.prm"

I posted on Tech Support Guy but it looked like this forum got much more traffic

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 12:51
by dbenham
The solution is much simpler. You want everything in the START command:
- the window title
- the directory to start in
- the program to run
- the parameters

Code: Select all

@echo off
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_1.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_2.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_3.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_4.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_5.prm"

A bit less typing:

Code: Select all

@echo off
for %%F in (
  "C:\temp\parameter_file_1.prm"
  "C:\temp\parameter_file_2.prm"
  "C:\temp\parameter_file_3.prm"
  "C:\temp\parameter_file_4.prm"
  "C:\temp\parameter_file_5.prm"
) do start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" %%F

or

Code: Select all

@echo of
setlocal
set cmd=start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe"
%cmd% "C:\temp\parameter_file_1.prm"
%cmd% "C:\temp\parameter_file_2.prm"
%cmd% "C:\temp\parameter_file_3.prm"
%cmd% "C:\temp\parameter_file_4.prm"
%cmd% "C:\temp\parameter_file_5.prm"


Dave Benham

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 13:16
by Squashman
signalMTB wrote:I posted on Tech Support Guy but it looked like this forum got much more traffic

Techguy is a high volume site but is not specific to batch files only like this site is. I am basically one of two or three people who will answer batch file questions on Techguy and the majority of the time it is me. I joined this site specifically for the reason to learn more from the experts here. I can do most of the normal stuff but most of the people here are above and beyond my knowledge base.

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 15:28
by signalMTB
dbenham wrote:The solution is much simpler. You want everything in the START command:
- the window title
- the directory to start in
- the program to run
- the parameters

Code: Select all

@echo off
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_1.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_2.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_3.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_4.prm"
start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" "C:\temp\parameter_file_5.prm"

A bit less typing:

Code: Select all

@echo off
for %%F in (
  "C:\temp\parameter_file_1.prm"
  "C:\temp\parameter_file_2.prm"
  "C:\temp\parameter_file_3.prm"
  "C:\temp\parameter_file_4.prm"
  "C:\temp\parameter_file_5.prm"
) do start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe" %%F

or

Code: Select all

@echo of
setlocal
set cmd=start "" /d "c:\Program Files\SaTScan" "SaTScanBatch.exe"
%cmd% "C:\temp\parameter_file_1.prm"
%cmd% "C:\temp\parameter_file_2.prm"
%cmd% "C:\temp\parameter_file_3.prm"
%cmd% "C:\temp\parameter_file_4.prm"
%cmd% "C:\temp\parameter_file_5.prm"


Dave Benham


sweet, that worked perfectly. thanks!!

Re: calling multiple sessions of an exe from CMD

Posted: 14 Jan 2012 15:40
by Squashman
And if you wanted to, we could create a script where you could drag and drop all your PARM files onto the batch file that you wanted to run. That is how most of my batch files are setup at work.

Re: calling multiple sessions of an exe from CMD

Posted: 15 Jan 2012 20:14
by signalMTB
Squashman wrote:And if you wanted to, we could create a script where you could drag and drop all your PARM files onto the batch file that you wanted to run. That is how most of my batch files are setup at work.


interesting, how would you do that??