Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab Assignment 4 Using Batch Files

Similar presentations


Presentation on theme: "Lab Assignment 4 Using Batch Files"— Presentation transcript:

1 Lab Assignment 4 Using Batch Files

2 Submitting the LABS for grading
Subject line of message: CTEC 110 WA Lab 4 Assignments Attachment file names: DOS Lab 4-A, DOS Lab 4-B, DOS Lab 4-C, DOS Lab 4-D, DOS Lab 4-E , DOS Lab 4-F Inserted Textual First Line of “each” Lab Assignment: Name, CTEC 110 WA, DOS Lab 4-A Name, CTEC 110 WA, DOS Lab 4-B Name, CTEC 110 WA, DOS Lab 4-C Name, CTEC 110 WA, DOS Lab 4-D etc… (Where Name is your first and last name such as: David Sims (Add one blank line after the first line for readability.) Lab 4 Assignments (24 slides) CTEC 110

3 4-A Activity Writing and Executing a Batch File
Setup the USB drive for use Clear the command screen Setup the disks for section 10 Change to the root of the O: Drive Create a batch file called EXAMPLE.BAT Lab 4 Assignments (24 slides) CTEC 110

4 4-A Activity Writing and Executing a Batch File
Enter the following commands: DIR *.NEW DIR G:\WUGXP\*.FIL Save the batch file Verify that the batch file exists Execute the batch file Snapshot the screen results and save Lab 4 Assignments (24 slides) CTEC 110

5 4-B Activity Creating a Shortcut for a Batch File
Right click on the Windows desktop Select new shortcut Type in the following: G:\WUGXP\GAMES\BOG2\BOG.EXE Select Next and give the name of “My BOG Game” for the shortcut Click Finish Lab 4 Assignments (24 slides) CTEC 110

6 4-B Activity Creating a Shortcut for a Batch File
You should now see: As a selection on your desktop now Right click the icon and select properties Push the “Change Icon” button Select Browse C:\Windows\System32\shell32.dll Open Choose the “golden star” icon to use and double click it Your icon should now be: Lab 4 Assignments (24 slides) CTEC 110

7 4-B Activity Creating a Shortcut for a Batch File
Now select the properties again for the shortcut on the desktop Use the snipping tool and take a “window snip” of the shown properties window Save the snap shot in a Word document for this activity Lab 4 Assignments (24 slides) CTEC 110

8 4-C Activity Using Replaceable Parameters
Clear the command screen Change to the root of the O Drive COPY CLASS\JUP.* COPY JUP.BUD JUP.XYZ Display the contents of the file JUP.XYZ Display the file name only at this location Destroy this file with ECHO > JUP.XYZ Display the contents again of JUP.XYZ Lab 4 Assignments (24 slides) CTEC 110

9 4-C Activity Using Replaceable Parameters
Display the file name again of JUP.XYZ Create a batch file called KILLIT.BAT Enter these commands: ECHO > JUP.XYZ TYPE JUP.XYZ DEL JUP.XYZ save the batch file Display the contents of KILLIT.BAT Execute this batch file Lab 4 Assignments (24 slides) CTEC 110

10 4-C Activity Using Replaceable Parameters
Re-Edit this file using notepad Add these lines to the top REM This batch file will make REM the data in a file difficult to recover. DIR %1 PAUSE You are going to kill the file, %1. Are you sure? Replace ECHO > JUP.XYZ with ECHO > %1 Delete the line: TYPE JUP.XYZ Replace DEL JUP.XYZ with DEL %1 Save the file and exit notepad Lab 4 Assignments (24 slides) CTEC 110

11 4-C Activity Using Replaceable Parameters
Display the contents of the KILLIT.BAT file Now use the batch file to kill the file JUP.BUD Check to see if the file is gone Snapshot the screen results and save Lab 4 Assignments (24 slides) CTEC 110

12 4-D Activity Multiple Replaceable Parameters
Clear the command screen Change to the root of the O Drive Create a new batch file called MULTI.BAT Enter the following commands: REM This is a sample batch file REM using more than one replaceable parameter TYPE %3 COPY %1 %2 TYPE %1 Save the batch file Lab 4 Assignments (24 slides) CTEC 110

13 4-D Activity Multiple Replaceable Parameters
Display the contents of MULTI.BAT COPY CLASS\VEN.* Give the following command: MULTI VEN.ABC JUP.ABC FILE2.SWT Snapshot the screen results and save Lab 4 Assignments (24 slides) CTEC 110

14 4-E Activity Multiple Replaceable Parameters
Clear the command screen Change to the root of the O: Drive Create a new batch file called NOCOPY.BAT Enter the following commands: REM This batch file, NOCOPY.BAT, will hide specified files, REM then copy all other files from one location to another, REM then unhide the original files. ATTRIB +H %1 COPY %3\*.* %2 ATTRIB -H %1 Save the batch file Lab 4 Assignments (24 slides) CTEC 110

15 4-E Activity Multiple Replaceable Parameters
Display the contents of NOCOPY.BAT Execute the batch file: NOCOPY CLASS\*.ABC TRIP CLASS Display the files with “ABC” as the extension in the directory CLASS Display the files with “ABC” as the extension in the directory TRIP Snapshot the screen results and save Lab 4 Assignments (24 slides) CTEC 110

16 4-F Activity Using CHOICE,CALL,GOTO & IF
We are going to create three batch files CHOOSE.BAT MENU.BAT OTHER.BAT CHOOSE.BAT will use a choice variable MENU.BAT is a called menu batch file OTHER.BAT will use CHOICE command Lab 4 Assignments (24 slides) CTEC 110

17 4-F Activity Using CHOICE,CALL,GOTO & IF
Clear the command screen Create the CHOOSE.BAT file: @ECHO OFF CLS ECHO. ECHO THIS IS THE CHOOSE.BAT BATCH FILE EXAMPLE! ECHO ############### ECHO 1. Print Hello ECHO 2. Print Bye ECHO 3. Print Test ECHO E To Exit this batch file Lab 4 Assignments (24 slides) CTEC 110

18 4-F Activity Using CHOICE,CALL,GOTO & IF
Continued..part 2: CHOOSE.BAT file SET /p choice=Type the number to print text. IF '%choice%'=='1' goto hello IF '%choice%'=='2' goto bye IF '%choice%'=='3' goto test IF '%choice%'=='E' goto stop IF not '%choice%'=='' ECHO "%choice%" is not valid please try again ECHO. goto END :HELLO ECHO Hello :BYE ECHO Bye Lab 4 Assignments (24 slides) CTEC 110

19 4-F Activity Using CHOICE,CALL,GOTO & IF
Continued..part 3: CHOOSE.BAT file goto END :TEST ECHO Test :END PAUSE GOTO START :STOP ECHO . ECHO You have chosen to terminate CHOOSE.BAT! Lab 4 Assignments (24 slides) CTEC 110

20 4-F Activity Using CHOICE,CALL,GOTO & IF
Create the MENU.BAT file: @ECHO off CLS ECHO. ECHO THIS IS THE OTHER.BAT and MENU.BAT BATCH FILE EXAMPLE ECHO ############### ECHO 1. Print Hello ECHO 2. Print Bye ECHO 3. Print Test ECHO E To Exit this batch file Lab 4 Assignments (24 slides) CTEC 110

21 4-F Activity Using CHOICE,CALL,GOTO & IF
Create the OTHER.BAT file: @ECHO off :BEGIN CALL MENU.BAT CHOICE /N /C:123E /M "MAKE YOUR SELECTION: " IF ERRORLEVEL ==4 GOTO STOP IF ERRORLEVEL ==3 GOTO TEST IF ERRORLEVEL ==2 GOTO BYE IF ERRORLEVEL ==1 GOTO HELLO ECHO Not a valid selection! please try again... ECHO. goto END :HELLO ECHO Hello Lab 4 Assignments (24 slides) CTEC 110

22 4-F Activity Using CHOICE,CALL,GOTO & IF
Continue..part 2: OTHER.BAT file :BYE ECHO Bye goto END :TEST ECHO Test :END PAUSE GOTO BEGIN :STOP ECHO . ECHO You have choosen to terminate OTHER.BAT! Lab 4 Assignments (24 slides) CTEC 110

23 4-F Activity Using CHOICE,CALL,GOTO & IF
Exit and save the batch file Type CHOOSE.BAT MENU.BAT OTHER.BAT Snapshot the screen and save Execute CHOOSE.BAT Enter 1 Enter 2 Enter 3 Enter E Snapshot the screen and add to bottom Lab 4 Assignments (24 slides) CTEC 110

24 4-F Activity Using CHOICE,CALL,GOTO & IF
Execute MENU.BAT Snapshot the screen and add to the bottom Execute OTHER.BAT Enter 1 Enter 2 Enter 3 Enter E Snapshot the screen results, add to the bottom and save After you are satisfied with all the DOS Lab activity results all the results to your instructor as one message with attachments. Lab 4 Assignments (24 slides) CTEC 110


Download ppt "Lab Assignment 4 Using Batch Files"

Similar presentations


Ads by Google