Question:
How to run multiple commands in a batch file?
?
2013-09-24 05:17:47 UTC
I am trying to create a Batch file that will open multiple Command Prompts and do constant pinging for my network.

I know I can do the follow:

-----------------------------------------------------

@echo off

ping -t www.google.com

start "C:\Windows\System32\cmd.exe"

-----------------------------------------------------

but that is all I can get.

Is there a command that will let me do another "ping -t " or "ping -t " inside of the command prompt that I am telling it to open?

Thank you,
Three answers:
?
2016-10-14 02:36:54 UTC
Batch File Multiple Commands
Adrian
2013-09-24 07:22:41 UTC
Command prompts can only run one command at a time. That is an old DOS feature - not multi-tasking.

You may be able to "spawn" other commands, like:

@echo off

command /k ping -t www.google.com

command /k ping -t www.next web site.com

pause



Use CMD for modern versions of Windows instead of "command"



However, depending on which version of Windows, that may or may not work. You mauy have to spawn different .BAT files with the CMD command line inside each.
2016-03-19 16:08:45 UTC
Heres a batch file which will work... @echo off call C:\batch1.bat cls call C:\batch2.bat cls call C:\batch3.bat exit Please note: If batch 1, 2, or 3 contain an "exit" command, this will close the file I have created above. To fix this, replace all "exit" commands in batches 1, 2, and 3 with "goto :EOF". This ends the script instead of closing the DOS window.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...