24
Lab Assignment 4 Using Batch Files

Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

Embed Size (px)

Citation preview

Page 1: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

Lab Assignment 4Using Batch Files

Page 2: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

Submitting the LABS for gradingSubject line of email 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-Detc…(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 2

Page 3: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-A ActivityWriting and Executing a Batch File

1. Setup the USB drive for use

2. Clear the command screen

3. Setup the disks for section 10

4. Change to the root of the O: Drive

5. Create a batch file called EXAMPLE.BAT

Lab 4 Assignments (24 slides) CTEC 110 3

Page 4: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-A ActivityWriting and Executing a Batch File

6. Enter the following commands:DIR *.NEW

DIR G:\WUGXP\*.FIL

7. Save the batch file

8. Verify that the batch file exists

9. Execute the batch file

10.Snapshot the screen results and save

Lab 4 Assignments (24 slides) CTEC 110 4

Page 5: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-B ActivityCreating a Shortcut for a Batch File1. Right click on the Windows desktop

2. Select new shortcut

3. Type in the following:G:\WUGXP\GAMES\BOG2\BOG.EXE

4. Select Next and give the name of “My BOG Game” for the shortcut

5. Click Finish

Lab 4 Assignments (24 slides) CTEC 110 5

Page 6: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-B ActivityCreating a Shortcut for a Batch File6. You should now see:

As a selection on your desktop now7. Right click the icon and select properties8. Push the “Change Icon” button9. Select Browse C:\Windows\System32\

shell32.dll10.Open11.Choose the “golden star” icon to use and

double click it12.Your icon should now be: Lab 4 Assignments (24 slides) CTEC 110 6

Page 7: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-B ActivityCreating a Shortcut for a Batch File13.Now select the properties again for the

shortcut on the desktop

14.Use the snipping tool and take a “window snip” of the shown properties window

15.Save the snap shot in a Word document for this activity

Lab 4 Assignments (24 slides) CTEC 110 7

Page 8: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-C ActivityUsing Replaceable Parameters

1. Clear the command screen

2. Change to the root of the O Drive

3. COPY CLASS\JUP.*

4. COPY JUP.BUD JUP.XYZ

5. Display the contents of the file JUP.XYZ

6. Display the file name only at this location

7. Destroy this file with ECHO > JUP.XYZ

8. Display the contents again of JUP.XYZLab 4 Assignments (24 slides) CTEC 110 8

Page 9: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-C ActivityUsing Replaceable Parameters

9. Display the file name again of JUP.XYZ

10.Create a batch file called KILLIT.BATEnter these commands:

ECHO > JUP.XYZ

TYPE JUP.XYZ

DEL JUP.XYZ

save the batch file

11.Display the contents of KILLIT.BAT

12.Execute this batch fileLab 4 Assignments (24 slides) CTEC 110 9

Page 10: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-C ActivityUsing Replaceable Parameters

13.Re-Edit this file using notepad14.Add these lines to the top

REM This batch file will makeREM the data in a file difficult to recover.DIR %1PAUSE You are going to kill the file, %1. Are you sure?

15.Replace ECHO > JUP.XYZ with ECHO > %1

16.Delete the line: TYPE JUP.XYZ17.Replace DEL JUP.XYZ with DEL %118.Save the file and exit notepadLab 4 Assignments (24 slides) CTEC 110 10

Page 11: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-C ActivityUsing Replaceable Parameters

19.Display the contents of the KILLIT.BAT file

20.Now use the batch file to kill the file JUP.BUD

21.Check to see if the file is gone

22.Snapshot the screen results and save

Lab 4 Assignments (24 slides) CTEC 110 11

Page 12: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-D ActivityMultiple Replaceable Parameters

1. Clear the command screen2. Change to the root of the O Drive3. Create a new batch file called MULTI.BAT4. Enter the following commands:

REM This is a sample batch fileREM using more than one replaceable parameterTYPE %3COPY %1 %2TYPE %1

5. Save the batch file

Lab 4 Assignments (24 slides) CTEC 110 12

Page 13: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-D ActivityMultiple Replaceable Parameters

6. Display the contents of MULTI.BAT

7. COPY CLASS\VEN.*

8. Give the following command:MULTI VEN.ABC JUP.ABC FILE2.SWT

9. Snapshot the screen results and save

Lab 4 Assignments (24 slides) CTEC 110 13

Page 14: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-E ActivityMultiple Replaceable Parameters

1. Clear the command screen2. Change to the root of the O: Drive3. Create a new batch file called NOCOPY.BAT4. 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 %1COPY %3\*.* %2ATTRIB -H %1

5. Save the batch fileLab 4 Assignments (24 slides) CTEC 110 14

Page 15: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-E ActivityMultiple Replaceable Parameters

6. Display the contents of NOCOPY.BAT

7. Execute the batch file:NOCOPY CLASS\*.ABC TRIP CLASS

8. Display the files with “ABC” as the extension in the directory CLASS

9. Display the files with “ABC” as the extension in the directory TRIP

10.Snapshot the screen results and save

Lab 4 Assignments (24 slides) CTEC 110 15

Page 16: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

1. We are going to create three batch filesCHOOSE.BATMENU.BATOTHER.BAT

2. CHOOSE.BAT will use a choice variable

3. MENU.BAT is a called menu batch file

4. OTHER.BAT will use CHOICE command

Lab 4 Assignments (24 slides) CTEC 110 16

Page 17: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

5. Clear the command screen6. Create the CHOOSE.BAT file:

@ECHO OFFCLSECHO.ECHO THIS IS THE CHOOSE.BAT BATCH FILE EXAMPLE!ECHO ###############ECHO 1. Print HelloECHO 2. Print ByeECHO 3. Print TestECHO E To Exit this batch fileECHO ###############

Lab 4 Assignments (24 slides) CTEC 110 17

Page 18: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

7. Continued..part 2: CHOOSE.BAT fileSET /p choice=Type the number to print text.IF '%choice%'=='1' goto helloIF '%choice%'=='2' goto byeIF '%choice%'=='3' goto testIF '%choice%'=='E' goto stopIF not '%choice%'=='' ECHO "%choice%" is not valid please try againECHO.goto END:HELLOECHO Hellogoto END:BYEECHO Bye

Lab 4 Assignments (24 slides) CTEC 110 18

Page 19: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

8. Continued..part 3: CHOOSE.BAT filegoto END:TESTECHO Testgoto END:ENDPAUSEGOTO START:STOPECHO .ECHO You have chosen to terminate CHOOSE.BAT!PAUSE

Lab 4 Assignments (24 slides) CTEC 110 19

Page 20: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

9. Create the MENU.BAT file:@ECHO offCLSECHO.ECHO THIS IS THE OTHER.BAT and MENU.BAT BATCH FILE EXAMPLEECHO ###############ECHO 1. Print HelloECHO 2. Print ByeECHO 3. Print TestECHO E To Exit this batch fileECHO ###############

Lab 4 Assignments (24 slides) CTEC 110 20

Page 21: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

10. Create the OTHER.BAT file:@ECHO off:BEGINCALL MENU.BATCHOICE /N /C:123E /M "MAKE YOUR SELECTION: "IF ERRORLEVEL ==4 GOTO STOPIF ERRORLEVEL ==3 GOTO TESTIF ERRORLEVEL ==2 GOTO BYEIF ERRORLEVEL ==1 GOTO HELLOECHO Not a valid selection! please try again...ECHO.goto END:HELLOECHO Hellogoto END

Lab 4 Assignments (24 slides) CTEC 110 21

Page 22: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

11. Continue..part 2: OTHER.BAT file:BYEECHO Byegoto END:TESTECHO Testgoto END:ENDPAUSEGOTO BEGIN:STOPECHO .ECHO You have choosen to terminate OTHER.BAT!PAUSE

Lab 4 Assignments (24 slides) CTEC 110 22

Page 23: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

12.Exit and save the batch file 13.Type CHOOSE.BAT MENU.BAT

OTHER.BAT14.Snapshot the screen and save15.Execute CHOOSE.BAT

Enter 1Enter 2Enter 3Enter E

16.Snapshot the screen and add to bottom

Lab 4 Assignments (24 slides) CTEC 110 23

Page 24: Lab Assignment 4 Using Batch Files. Submitting the LABS for grading Subject line of email message: CTEC 110 WA Lab 4 Assignments Attachment file names:

4-F ActivityUsing CHOICE,CALL,GOTO & IF

17.Execute MENU.BAT18.Snapshot the screen and add to the bottom19.Execute OTHER.BAT

Enter 1Enter 2Enter 3Enter E

20.Snapshot the screen results, add to the bottom and save

21.After you are satisfied with all the DOS Lab activity results email all the results to your instructor as one message with attachments.

Lab 4 Assignments (24 slides) CTEC 110 24