Batch file to open multiple instances of cmd and run Ruby script in each instance

1.3k views Asked by At

I'm trying to open multiple instances of cmd up which each run a ruby script at the same time. For background into the scripts, each of these ruby scripts run watir-webdriver and spawn new browser instances. All of this should happen instantaneously.

Here's what I've tried:

start cmd /k
cd %USERPROFILE%\Desktop
ruby script_1.rb
start cmd /k
cd %USERPROFILE%\Desktop
ruby script_2.rb
start cmd /k
cd %USERPROFILE%\Desktop
ruby script_3.rb

However, only two cmd prompts opened and in the second one it just sits at the C:\Users\test\Desktop and doesn't run the command. I commented out each of the three ruby commands and then ran it and it opened up all three cmd prompts.

1

There are 1 answers

0
JosefZ On BEST ANSWER

Try next approach:

pushd %USERPROFILE%\Desktop
start "1" cmd /k ruby script_1.rb
start "2" cmd /k ruby script_2.rb
start "3" cmd /k ruby script_3.rb