calling multiple sessions of an exe from CMD

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
signalMTB
Posts: 5
Joined: 14 Jan 2012 09:45

calling multiple sessions of an exe from CMD

#1 Post by signalMTB » 14 Jan 2012 09:48

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: calling multiple sessions of an exe from CMD

#2 Post by dbenham » 14 Jan 2012 10:17

Check out the START command (type START /? to get help)

Dave Benham

signalMTB
Posts: 5
Joined: 14 Jan 2012 09:45

Re: calling multiple sessions of an exe from CMD

#3 Post by signalMTB » 14 Jan 2012 10:31

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.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: calling multiple sessions of an exe from CMD

#4 Post by Squashman » 14 Jan 2012 11:23

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.

signalMTB
Posts: 5
Joined: 14 Jan 2012 09:45

Re: calling multiple sessions of an exe from CMD

#5 Post by signalMTB » 14 Jan 2012 11:42

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: calling multiple sessions of an exe from CMD

#6 Post by dbenham » 14 Jan 2012 12:51

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

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: calling multiple sessions of an exe from CMD

#7 Post by Squashman » 14 Jan 2012 13:16

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.

signalMTB
Posts: 5
Joined: 14 Jan 2012 09:45

Re: calling multiple sessions of an exe from CMD

#8 Post by signalMTB » 14 Jan 2012 15:28

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!!

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: calling multiple sessions of an exe from CMD

#9 Post by Squashman » 14 Jan 2012 15:40

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.

signalMTB
Posts: 5
Joined: 14 Jan 2012 09:45

Re: calling multiple sessions of an exe from CMD

#10 Post by signalMTB » 15 Jan 2012 20:14

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??

Post Reply