0% found this document useful (0 votes)
64 views

Activity One: Code: Cls Echo %computername% Dir Pause

This document contains code snippets from multiple batch script activities. Activity 1 contains basic commands to clear the screen, display the computer name, and pause. Activity 2 contains a more advanced batch script with comments and commands to clear the screen, display text, list the directory, and pause. Activity 3 is a repeat of Activity 2. Activities 4-6 contain batch scripts that prompt for user input, perform calculations, copy files between directories. Activity 6 provides two versions, one that manually sets variables and one that prompts the user. Activity 7 provides two versions, one that manually sets drive sizes and one that prompts the user, to calculate and display the total disk size.

Uploaded by

pianodiva007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Activity One: Code: Cls Echo %computername% Dir Pause

This document contains code snippets from multiple batch script activities. Activity 1 contains basic commands to clear the screen, display the computer name, and pause. Activity 2 contains a more advanced batch script with comments and commands to clear the screen, display text, list the directory, and pause. Activity 3 is a repeat of Activity 2. Activities 4-6 contain batch scripts that prompt for user input, perform calculations, copy files between directories. Activity 6 provides two versions, one that manually sets variables and one that prompts the user. Activity 7 provides two versions, one that manually sets drive sizes and one that prompts the user, to calculate and display the total disk size.

Uploaded by

pianodiva007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Activity One:

Code
cls
echo %computername%
Dir
PAUSE
Screenshot

Activity Two:
Code
@ECHO OFF
CLS
REM Program: script2.bat
REM Author:
REM Date: 28-Mar-2014
REM Purpose: This is my first batch file
REM ----------------------------------------Pause

Echo My First Batch File


Dir
Echo You Just Saw Directory Listing
Echo Hello, %USERNAME%
Echo Bye For Now
Pause
Screenshot

Activity Three:
Code
@ECHO OFF
CLS
REM Program: script2.bat

REM Author:
REM Date: 28-Mar-2014
REM Purpose: This is my first batch file
REM ----------------------------------------Pause
Echo My First Batch File
Dir
Echo You Just Saw Directory Listing
Echo Hello, %USERNAME%
Echo Bye For Now
Pause
Screenshot

Activity Two:
Code
@ECHO OFF
CLS
REM Program: script2.bat
REM Author:
REM Date: 28-Mar-2014
REM Purpose: This is my first batch file
REM ----------------------------------------Pause
Echo My First Batch File
Dir
Echo You Just Saw Directory Listing
Echo Hello, %USERNAME%
Echo Bye For Now
Pause
Screenshot

Activity Three:
Code
@ECHO OFF
REM Program: script3.bat
REM Author:
REM Date: 2015-04-08
REM Purpose: ECHO example
REM ----------------------------TITLE COPS1104-Batch files
CLS
COLOR 57
ECHO.
ECHO This is my fourth batch file
ECHO.
DIR

ECHO I am testing some commands.


ECHO
ECHO I will use these commands in batch file.
ECHO on
Pause
Screenshot

Activity Four:
Code
@ECHO OFF
CLS
SET /P name= Please enter your name:
ECHO Your name is %name%
PAUSE
Screenshot

Activity Five:
Code
CLS
@ECHO OFF
REM Program: script5.bat
REM DATE: 205-04-08
REM Purpose: Finding the total marks
REM -----------------------------------------------------------

SET /P asn_marks= Please enter the assignment mark:


SET /P exam_marks= Please enter the mark for exam:

SET /A final_marks= asn_marks + exam_marks


ECHO Your final mark is %final_marks%
PAUSE
Screenshot

Activity 6:
Code
CLS
@ECHO OFF
SET SRC= c:\batch
SET DST= c:\batch2
CD\

10

MD %DST%
COPY %SRC% %DST%

PAUSE

Code V2
CLS
@ECHO OFF
SET SRC= c:\batch
SET DST= c:\batch2
CD\
MD %DST%
COPY %SRC% %DST%

PAUSE
Screenshot

11

12

13

Activity 6:
Code
CLS
@ECHO OFF

REM Program: script7.bat


REM Purpose: Adding drive C and D to find disk size
REM -------------------------------------------------------

SET driveC=20GB
SET driveD= 180GB
14

SET /A disk_size= driveC+driveD

ECHO %disk_size% GB
PAUSE
Code V2
CLS
@ECHO OFF

REM Program: script7.bat


REM Purpose: Adding drive C and D to find disk size
REM -------------------------------------------------------

SET /P driveC=Please enter the amount of GB in drive C:


SET /P driveD=Please enter the amount of GB in drive D:

SET /A disk_size= driveC+driveD

15

ECHO The total disk size taken up is %disk_size% GB


PAUSE
Screenshot

16

You might also like