Complete Batch Programming Chapter-3 | Learn Batch Commands

We will write Batch Commands in batch programming It is the native programming offered by the Microsoft Windows Operating System. Batch file is created using any text editors like WordPadNotepadWinWord or so on, which comprises of a sequence of built-in commands used to perform some often done tasks like deleting a series of files of same type or of different type, creating logs, clearing unwanted craps  from your computer and even for creating a batch VIRUS and much more uses of batch programming. Whenever a Batch program is executed, it was interpreted line-by-line by the CLI (Command Line Interpreter) command.com or the cmd.exe. Batch file is really helpful in automating tedious tasks and for maintaining system logs. The commands used while creating a batch file are case insensitive, in the sense that it may accept both small and upper case letters. 

Chapter-1: Click Here
Chapter-2: Click Here

Its is chapter 3 of our batch programming series. In this chapter we will learn network troubleshooting commands. So, let's get started.


Complete Batch Programming Chapter-3 | Learn Batch Commands


Network Troubleshooting Commands


Net:

The ‘net’ command is used for both local and remote troubleshooting and provides lot of features, and has 21 different sub-commands, and each sub commands have its own switches. To know what were the sub commands available for the ‘net’ command you can use the ‘net’ command.

First let’s discuss about the basic operations that this command offers and then move on the next level.

The ‘net’ command when used with the subcommand ‘user’ is used for creating, deleting and setting a password for an existing or a newly created user account. 

The ‘net users’ command along with the ‘/add’ switch is used to create a new user account. The below command is used to create a new user account with the name ‘technical point’ and password ‘passwords’ on the local machine.

C:\>net users technical password /add 
The command completely successfully.

Once the user was created successfully then it will display you with the message “command completed successfully”. The user that you created using the ‘net user’ command has only the normal user privileges, whereas it doesn’t have few rights such as installing a new software, access to few files and folders are restricted and so on.

To change the password for the user account ‘technical’ I can use the following command,
C:\>net users technical *
Type a password for the user:
Retype the password to confirm:
The command completed successfully.  
When the asterisk symbol is used after the ‘net users’ command followed by the ‘username’, it will prompt for the new password. This will work, only if you have the administrator or the power user privileges on that machine but you can change your own password, else the access will be denied.

The ‘net users’ command with the ‘/delete’ switch is used to delete the specified user account. The command given below is used to delete the user account named ‘technical’ from the local machine.
C:\>net users technical /delete 
The command completed successfully.

Once the specified user account was deleted, then you will be displayed with a message “The command completed successfully’.

The ‘/times’ switch is used to specify the ‘logon hours allowed’ for the specified user, if it is specified as ‘all’ then the user will be able to logon at any time, and if you are not specifying anything for the ‘times’ switch, then the ‘logon hours allowed’ will be set to none.
C:\>net users admin /times:all  
The command completed successfully.

In the above example, I have set the ‘logon hours allowed’ for the user ‘admin’ as all, so that user will be able to logon to this computer at any time.

To view the detailed information about a specified user such as account information, password information like password last set, password expiry, password whether changeable, whether user has the rights to change the password, local group membership and the global group membership of the user, you can use the ‘net user’ command followed by the username. For example if I want to know the details of the user ‘admin’ then I can use the below command,
C:\>net users admin  
The ‘/comment’ switch is used for giving comments the usergroup that you are going to create. In the following example I have created a new usergroup as the moderator and commented it as “Moderator user group”,

C:\>net localgroup Moderator /add /comment:"Moderator user Group"  
The command completed successfully.

The ‘/domain’ switch is used to add the user group under the specified domain.

The ‘/delete’ switch is used for deleting the user from a group. The following command is used for deleting the newly created group ‘moderator’,

C:\>net localgroup Moderator /delete
The command completed successfully.

The ‘net’ command when used with the ‘view’ subcommand is used to display the hostnames of all the computers that are connected in the same network. If you are not in a networked machine, then it will display the following message,
C:\>net view  
There are no entries in the list.

The ‘net’ command along with the ‘view’ sub command is used to view the computers connected within the same network. When this command gets executed it will display the hostnames with its description if any. If this command is executed in a machine which is not hooked up in a network then it will display the message “There are no entries in the list.”.

The ‘net view’ when used with the ‘/cache’ switch is used to display the cached information on the host. The ‘/All’ switch is used to display all the connected hosts that is in the same network, no matter whether the machine is online or offline.

The ‘net time’ command is used to display the time from the configured time server if specified.

The ‘net start’ command is used to start a service that is supported by your computer. If you are not aware of the services associated with the computer, then type ‘services.msc’ in the run dialog box or in the command console to view all available services that are supported by your computer.

The following command is used to start the ‘printer spooler’ service in your computer,
C:\>net start spooler
The Print Spooler service is starting.
The Print Spooler service was started successfully.  
You will get the following error message, if this service was already started and running,
C:\>net start spooler
The requested service has already been started. 

Ping:

The ‘PING’ command is short for “Packet Inter Net Gopher” which is used for testing the connectivity between two hosts on the same network. This command is also used to check whether the NIC (Network Interface Card) is in good working condition. For example, to check whether the NIC is working fine, then I have to ping the localhost either by using the hostname or by the IP address. As we already know that the loopback IP for a local machine is 127.0.0.1, I am pinging the localhost using the loopback IP.

Ping of Death:

As mentioned in the note, the maximum size of a datagram is 65,535. Earlier, there was a bug in the ping, whereas by using the ‘-l’ option any one can set the packet size more than the maximum size (65,535), so when a giant packet is sent to the target machine, it doesn’t know how to handle such a big packet and as a result the machine simply crashes, hangs or reboots which leads to DoS attack thereby denying the services offered by the remote machine. For example, if I want to crash the remote machine 10.199.64.65, then I can use the below command by setting the size more than the maximum size allowed,
C:\>ping –l 65550 10.199.64.65
When the machine ’10.199.64.65’ receives the packet sent by my machine, then it will crash, hangs or reboots. This bug was patched once it came into the developer’s vision, and it will not work nowadays, moreover the maximum size of a packet that you can set is restricted to 65,500.

The ‘-f’ switch is used to tell the ping command not to fragment the packets. The ‘-I’ switch is used to specify the TTL (Time To Live) value of the packet. Every OS has its own TTL value set to its packets, the default TTL value for a packet sent from a Windows XP machine is TTL=128. The ‘-v’ switch is used to set the ToS (Type of Service). The ‘-s’ switch is used to set the timestamp for each hops.

The ‘-j’ and ‘-k’ switches are almost similar to each other where both of them is used for loose sourcing when given with a host list in a external text file, where as ‘-k’ switch will force the packets to pass through the host specified in the list. Both the switch really helps in testing whether the routers and other networking device is the network is working fine or not.
C:\>ping –j hostfile.txt 10.199.64.70  
The ‘-w’ switch is used for setting the delay time or the wait time for the ECHO reply to reach the source machine.

Telnet:

The ‘telnet’ command is used to connect to a remote host either by using its hostname or by its IP address. If I want to connect to a remote machine that has the hostname ‘production-server’, then I can use the below command,
C:\>telnet production-server
By default the telnet daemon runs on the port number 23, and also establishes connection to the port 23 on the remote machine too. Once the command is executed, then the remote machine will prompt for credentials like username and password, and after the successful authentication you can do whatever you wish to do with the remote machine.

When the ‘-a’ switch is used, then the telnet will attempt to automatically logon to the remote host.

The ‘-f’ switch is used for specifying the client side logging, so that it will log all the successful connection, failed connection, refused connections and so on. The ‘-l’ switch when used will logon to the remote machine using the local user credentials. The ‘-t’ is used for specifying the terminal type, the supported terminals are vt100, vt52, ansi and vtnt.

telnet can also be used to connect with a different port when specified, for example, if I wish to connect to the FTP port using the telnet, then I have to specify the port number as 21 and have to execute the below command,
C:\>telnet 10.199.64.66 21  
The above command will connect to the remote machine which has the IP address ’10.199.64.66’ on the FTP port.

Also ReadTop 10+ Famous Hackers In The World
Also Read:  Top 4 Password Cracking Techniques | Password Hacking
Also Read:  Top 10+ Amazing Notepad Viruses | Batch Programming

This Will Update Time to Time
Please Keep Visiting 
& Thanks For Visiting



Post a Comment

2 Comments