Networking in Batch Script

MD Aminul Islam Jan 30, 2023
  1. the NET ACCOUNTS Command in Batch
  2. the NET CONFIG Command in Batch
  3. the NET COMPUTER Command in Batch
  4. the NET USER Command in Batch
  5. the NET STOP/START Command in Batch
  6. the NET STATISTICS Command in Batch
  7. the NET USE Command in Batch
Networking in Batch Script

In this article, we will talk about various commands in Batch for networking. We will see the use of these commands with necessary examples and explanations.

the NET ACCOUNTS Command in Batch

Through this command, you can look at the current restrictions and passwords for your computer. Now we will run this command on our CMD and see what the output becomes.

NET ACCOUNTS

After running the command, you will see this output shown below. You can see all the necessary information regarding your network.

Output:

Force user logoff how long after time expires?:       Never
Minimum password age (days):                          0
Maximum password age (days):                          42
Minimum password length:                              0
Length of password history maintained:                None
Lockout threshold:                                    Never
Lockout duration (minutes):                           30
Lockout observation window (minutes):                 30
Computer role:                                        WORKSTATION
The command completed successfully.

the NET CONFIG Command in Batch

This command is used to display the settings of the current server and workgroups. Let’s run this command and see what happens.

NET CONFIG

After executing the command, you will get the below output.

Output:

The following running services can be controlled:

   Server
   Workstation

the NET COMPUTER Command in Batch

The main purpose of this command is to remove a computer attached to the Windows domain controller. The general format of the command is NET COMPUTER \\computername {/ADD | /DEL}.

Let’s see an example.

NET COMPUTER \\MyComputer /ADD

the NET USER Command in Batch

This is the most important command for networking because this command can view, add, delete or modify a user account. To view details of a specific user, you need to follow this format NET USER USER_NAME.

Let’s see a basic example of this command.

NET USER

After executing the command, you will see:

Output:

User accounts for \\DESKTOP-NRTA4BB

-------------------------------------------------------------------------------
Administrator            DefaultAccount           Guest
Author                   Alen                    WDAGUtilityAccount
The command completed successfully.

the NET STOP/START Command in Batch

This command is mainly used to start or stop specific networking services. The general format for this command is NET STOP/START SERVICE_NAME.

the NET STATISTICS Command in Batch

Suppose you want to see the network statistics of your server or workstation; you need to use this command. Let’s see an example with this command.

NET STATISTICS Workstation

You will get the below output.

Workstation Statistics for \\DESKTOP-NRTA4BB


Statistics since 6/3/2022 7:55:04 AM


  Bytes received                               13524
  Server Message Blocks (SMBs) received        4
  Bytes transmitted                            12006
  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                                    4
  Failed use count                             0

The command completed successfully.

the NET USE Command in Batch

This command connects or disconnects a computer from a shared resource. Also, this command can show the necessary information about the existing connections.

The general format for this command is NET USE C: \\YourComputer\Test.

Note
The code we shared in this article is written in Batch and only for the Windows CMD.
MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn