Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Department of Information Technology

Faculty of Engineering and Technology


University of Sindh Jamshoro

LAB # 2
BSIT (Part-III)
SENG- 529 Operating Systems
Command Prompt Scripting and Batch Filing
Student Name________________________________ Role No___________________________

LAB OBJECTIVE: To understand and work with windows command prompt scripting and
batch files

TERMINOLOGIES:

Batch files: a computer file containing a list of instructions to be carried out in turn.

Scripting languages: A scripting or script language is a programming language that supports


scripts: programs written for a special run-time environment that automate
the execution of tasks that could alternatively be executed one-by-one by a
human operator. Scripting languages are often interpreted (rather than
compiled)

PRACTICAL EXERCISES

Create a bat file having following code, execute it and check the output

ipconfig /all
ping google.com
tracert google.com
PAUSE

Create a bat file having following code, execute it and check the output

Echo off
ipconfig /all
ping google.com
tracert google.com
PAUSE

Create a bat file having following code, execute it and check the output written in results.txt
file
ECHO OFF
ipconfig /all >> results.txt
ping google.com >> results.txt
tracert google.com >> results.txt

Arithmetic Operators

Operator Description

+ (Addition) Adds values on either side of the operator.

- (Subtraction) Subtracts right-hand operand from left-hand operand.

* Multiplies values on either side of the operator.


(Multiplication)

/ (Division) Divides left-hand operand by right-hand operand.

Divides left-hand operand by right-hand operand and


% (Modulus)
returns remainder.

Arithmetic operation
echo off
set a= 10
set b= 20
set /a c = %a%+%b%
echo addition is (%c%)

If statement Syntax
If Condition
Statements
Try this code
IF NOT DEFINED _example ECHO Value Missing

FOR YOU
Write batch script which:
o Computes product and difference of two number
o Prints the result on screen with appropriate message
o And writes output in text file.

You might also like