JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM >

Running multiple commands simultaneously in a batch script

Author:JIYIK Last Updated:2025/03/21 Views:

Sometimes, we have to perform multiple tasks in the system at a time. This process is called multitasking. In batch scripts, we can run multiple commands at a time.

This article will show how to run multiple commands simultaneously, and we will also see some examples and explanations to make the topic easier.


Running multiple commands simultaneously in a batch script

Before you begin, please note that the set of commands you wish to run simultaneously should be independent. This means that one command should not depend on another.

In this article, we will discuss two different ways to run things at the same time. Suppose we want to run the following commands at once,

ping www.google.com
ipconfig /displaydns
Net statistics Workstation

These commands are mainly used to delete cache

Create a .bat file containing the commands

In this section, we will perform the following steps:

  • First, we have to open Notepad and write the command shared above.
  • We need a file with a .bat extension.
  • Now you need to clear your DNS cache. You can do this by simply double-clicking on the file.

Using special characters

Here, we will use a special character to achieve this. You can also follow this method.

We will &combine all four steps using the operator as follows:

ping www.google.com & ipconfig /displaydns & Net statistics Workstation

Here, if you want to execute one command after another is successfully executed, you can use &&instead of &.

For both methods, you will get output similar to the following:

Pinging www.google.com [142.250.195.100] with 32 bytes of data:
Reply from 142.250.195.100: bytes=32 time=59ms TTL=114
Reply from 142.250.195.100: bytes=32 time=60ms TTL=114
Reply from 142.250.195.100: bytes=32 time=60ms TTL=114
Reply from 142.250.195.100: bytes=32 time=58ms TTL=114

Ping statistics for 142.250.195.100:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 58ms, Maximum = 60ms, Average = 59ms

Windows IP Configuration

    ec2-52-23-111-175.compute-1.amazonaws.com
    ----------------------------------------
    Record Name . . . . . : ec2-52-23-111-175.compute-1.amazonaws.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 8903
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 52.23.111.175


    www.google.com
    ----------------------------------------
    Record Name . . . . . : www.google.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 174
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 142.250.195.100


    cdn.discordapp.com
    ----------------------------------------
    Record Name . . . . . : cdn.discordapp.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 137
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 162.159.129.233


    Record Name . . . . . : cdn.discordapp.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 137
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 162.159.133.233


    Record Name . . . . . : cdn.discordapp.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 137
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 162.159.134.233


    Record Name . . . . . : cdn.discordapp.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 137
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 162.159.135.233


    Record Name . . . . . : cdn.discordapp.com
    Record Type . . . . . : 1
    Time To Live  . . . . : 137
    Data Length . . . . . : 4
    Section . . . . . . . : Answer
    A (Host) Record . . . : 162.159.130.233


Workstation Statistics for \\DESKTOP-NRTA4BB


Statistics since 9/25/2022 1:33:19 PM


  Bytes received                               667340
  Server Message Blocks (SMBs) received        84
  Bytes transmitted                            611958
  Server Message Blocks (SMBs) transmitted     0
  Read operations                              0
  Write operations                             0
  Raw reads denied                             0
  Raw writes denied                            0

  Network errors                               0
  Connections made                             0
  Reconnections made                           0
  Server disconnects                           0

  Sessions started                             0
  Hung sessions                                0
  Failed sessions                              0
  Failed operations                            0
  Use count                                    84
  Failed use count                             0

The command completed successfully.

Windows IP Configuration

No operation can be performed on Ethernet while it has its media disconnected.
No operation can be performed on Local Area Connection* 1 while it has its media disconnected.
No operation can be performed on Local Area Connection* 2 while it has its media disconnected.

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 1:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::6cf3:f1dd:2862:c40c%19
   IPv4 Address. . . . . . . . . . . : 192.168.0.159
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

We have discussed the methods of running multiple commands simultaneously using batch scripts. You can use any of them according to your requirement.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Transferring files to Raspberry Pi using batch script

Publish Date:2025/03/21 Views:56 Category:OPERATING SYSTEM

This article will show a batch command that transfers a file from Windows to the Raspberry Pi environment and executes the file. PuTTY is a third-party free tool that implements Telnet and SSH for Windows and Unix platforms for free. It als

Renaming part of a file name in a batch script

Publish Date:2025/03/21 Views:122 Category:OPERATING SYSTEM

Sometimes we need to rename a series of files in a specific order. Most project files contain this sequence, and we can easily do this in a batch script using a simple one-line command. This short article will show us how to change a specif

Run batch scripts using Task Scheduler

Publish Date:2025/03/21 Views:152 Category:OPERATING SYSTEM

This article will show you how to use Task Scheduler to run a batch file. Run batch scripts using Task Scheduler With Task Scheduler, you can automate tasks to run automatically at specific times. It only takes a few steps and you don't nee

Mapping a network drive in a batch script

Publish Date:2025/03/21 Views:69 Category:OPERATING SYSTEM

This article will discuss how to map a network drive in a batch script. Mapping a network drive in a batch script For this purpose, we will see three formats of the same command. However, the general format of the command is: net use P: "\\

Copy files using batch script

Publish Date:2025/03/21 Views:91 Category:OPERATING SYSTEM

Batch scripts are scripts built specifically for the Windows command line to perform a variety of tasks and execute user-directed sequences of commands. Batch scripts make it easy to use Windows PowerShell. This article will explain how to

Downloading files from URL in batch script

Publish Date:2025/03/21 Views:63 Category:OPERATING SYSTEM

Today we have several download managers to download necessary files from the Internet. In addition, there is a download manager integrated into every web browser. But you can create a batch script that can also perform a similar task of dow

Running a batch script in silent mode

Publish Date:2025/03/21 Views:112 Category:OPERATING SYSTEM

If you run CMD without silent mode, the command prompt will print every line of code in CMD. This article will show you how to activate CMD silent mode via batch script. We will also learn different ways to run batch scripts silently. We wi

Run .exe file from command prompt using batch script

Publish Date:2025/03/20 Views:77 Category:OPERATING SYSTEM

This article will show you how to use a batch (.bat) script to run a .exe type file. You can use two different commands to achieve this. Let’s discuss each method in the following sections. Run .exe file from command prompt using title an

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial