Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Microsoft Support > Windows Vista/Windows 7 Support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Reply
 
LinkBack Thread Tools
Old 09-29-2009, 04:39 AM   #1 (permalink)
Registered User
 
billybong001's Avatar
 
Join Date: Feb 2009
Location: Singapore
Posts: 19
OS: Vista Ultimate (SP1)

My System

[SOLVED] Batch file: multiple instances of a CMD command.

Hi all,

I would like to simultaneously launch multiple instances of a single CMD command. How do I write a batch file to do so?

Regards,
Nicholas.
billybong001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 09-29-2009, 04:47 AM   #2 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,125
OS: Windows 7, Vista Ultimate

My System

Re: Batch file: multiple instances of a CMD command.

Quote:
Originally Posted by billybong001 View Post
Hi all,

I would like to simultaneously launch multiple instances of a single CMD command. How do I write a batch file to do so?

Regards,
Nicholas.

Hi Nicholas -

For info, you can type cmd /? for details on the switches available with cmd.

To answer your question, try cmd /k - that will execute the command and then keep running.

Regards. . .

jcgriff2

.
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 04:53 AM   #3 (permalink)
Registered User
 
billybong001's Avatar
 
Join Date: Feb 2009
Location: Singapore
Posts: 19
OS: Vista Ultimate (SP1)

My System

Re: Batch file: multiple instances of a CMD command.

I don't think you get the idea. For example, I can launch an instance of command prompt and type

ping www.website.com -t

It will continue the process until I press control C.

However I want now to launch for example, three separate instances of command prompt. How do I do this using a batch file rather than manually starting command prompt and entering the command?

Regards,
Nicholas.
billybong001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 05:05 AM   #4 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,125
OS: Windows 7, Vista Ultimate

My System

Re: Batch file: multiple instances of a CMD command.

Enter the commands into a notepad then save it as a BAT file.
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 05:10 AM   #5 (permalink)
Registered User
 
billybong001's Avatar
 
Join Date: Feb 2009
Location: Singapore
Posts: 19
OS: Vista Ultimate (SP1)

My System

Re: Batch file: multiple instances of a CMD command.

That is not what I wanted. It simply launches the same command over and over again in one instance of command prompt. I need the same command running in multiple instances.

Regards,
Nicholas.
billybong001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 05:41 AM   #6 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,125
OS: Windows 7, Vista Ultimate

My System

Re: Batch file: multiple instances of a CMD command.

try this - copy to bat file an execute it
Code:
start cmd /k ping www.website.com -t & start ping www.website.com -t & start ping www.website.com -t
I should warn you to beware of the 3 windows that will fly out at you.

jcgriff2

.
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !

Last edited by jcgriff2; 09-29-2009 at 05:53 AM.
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 06:35 AM   #7 (permalink)
Registered User
 
billybong001's Avatar
 
Join Date: Feb 2009
Location: Singapore
Posts: 19
OS: Vista Ultimate (SP1)

My System

Re: Batch file: multiple instances of a CMD command.

Hmm, running that batch file caused an infinite loop of command prompt windows. Which eventually forced me to reset the computer. Currently, the lines:

start cmd -ping www.website.com
start cmd -ping www.website.com
start cmd -ping www.website.com
pause

Successfully call out 3 windows, but they do not automatically run the ping command.

Regards,
Nicholas.

Edit: the command prompt points to the Desktop instead of it's default (users\username). As a result I am unable to use any system commands.

Last edited by billybong001; 09-29-2009 at 06:41 AM.
billybong001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-29-2009, 08:18 AM   #8 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,125
OS: Windows 7, Vista Ultimate

My System

Re: Batch file: multiple instances of a CMD command.

Hi -

I used the command that you provided... I didn't think anything of it. Where did you get it from? I have changed the command to timeout at 5 seconds - after launching the 3 separate windows.

Place these into a Notepad, name w/ BAT file ext and execute it -
Code:
 
start cmd /k PING 1.1.1.1 -n 1 -w 5000 >NUL 
start cmd /k PING 1.1.1.1 -n 1 -w 5000 >NUL 
start cmd /k PING 1.1.1.1 -n 1 -w 5000 >NUL 
`

A screenshot of my system is attached. 4 cmd/DOS screens total.

Regards. . .

jcgriff2

.
Attached Images
File Type: jpg screenshot_jcgriff2_DOS.JPG (209.9 KB, 6 views)
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-30-2009, 05:52 AM   #9 (permalink)
Registered User
 
billybong001's Avatar
 
Join Date: Feb 2009
Location: Singapore
Posts: 19
OS: Vista Ultimate (SP1)

My System

Re: Batch file: multiple instances of a CMD command.

Thank you jcgriff2, that was absolutely perfect.

I typed out what I would typically enter into command prompt after Users\nicky9499>
It seems I was missing out the /k tags to make it execute.

Speaking of which, what does the /k and >NUL do?

Regards,
Nicholas.

Last edited by billybong001; 09-30-2009 at 05:54 AM.
billybong001 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-30-2009, 08:26 AM   #10 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,125
OS: Windows 7, Vista Ultimate

My System

Re: Batch file: multiple instances of a CMD command.

Quote:
Originally Posted by billybong001 View Post

Thank you jcgriff2, that was absolutely perfect.

I typed out what I would typically enter into command prompt after Users\nicky9499>
It seems I was missing out the /k tags to make it execute.

Speaking of which, what does the /k and >NUL do?

Regards,
Nicholas.

Hi Nicholas. . .

I am glad that the "final version" is what you were looking for!

The parm /k tells the cmd/DOS windows from which the command was executed to stay open

>NUL directs the output to go nowhere sort of like ECHO OFF

You can get a full listing of these parms. Copy/paste the following -
Code:
 cmd /? > %temp%\1 & start notepad %temp%\1
A notepad will open with the results.

Regards. . .

jcgriff2

.
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 02:29 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85