CHAPTER OUTLINETEACHING SUGGESTIONSBATCH FILE COMMANDSA REVIEW OF THE REM, PAUSE, AND ECHO COMMANDSADVANCED FEATURES OF ECHO AND REMACTIVITY—USING ECHO AND NULTHE GOTO COMMANDACTIVITY—USING THE GOTO COMMANDTHE SHIFT COMMANDACTIVITY—USING THE SHIFT COMMANDTHE IF COMMANDTHE IF COMMAND USING STRINGSACTIVITY—USING THE IF COMMAND WITH STRINGSTESTING FOR NULL VALUESACTIVITY—USING NULL VALUESTHE IF EXIST/IF NOT EXIST COMMANDACTIVITY—USING IF EXIST TO TEST FOR A FILEIF ERRORLEVEL COMMAND TESTINGACTIVITY—USING IF ERRORLEVEL WITH COPYWRITING PROGRAMS TO TEST FOR KEY CODESACTIVITY—WRITING A SCRIPT FILETHE ENVIRONMENTACTIVITY—USING SET AND THE ENVIRONMENTAL VARIABLESUSING SET AND THE ENVIRONMENT IN BATCH FILESACTIVITY—USING SET AND THE ENVIRONMENT IN BATCH FILESTHE DIRCMD ENVIRONMENTAL VARIABLEACTIVITY—USING DIRCMDTHE FOR…IN…DO COMMANDACTIVITY—USING THE FOR…IN…DO COMMANDMORE FEATURES OF THE FOR…IN…DO COMMANDACTIVITY—USING THE ADDITIONAL FEATURES OF THE FOR…IN…DO COMMANDDEL %2THE CALL COMMANDACTIVITY—USING CALLSECTION 11.28 (p. 602)SECTION 11.29 (pp. 602-611)SECTION 11.30 (pp. 611-612)Activity 11.6 - Using the GOTO CommandActivity 11.15: Using IF EXIST to Test for a FILEBatch File by Line Number Test TRUE Processing Test FALSEInstructor: Prof. Michael P. Harris Chapter 11ITSC 1405 – Intro to PC Operating Systems Advanced BATCH FilesChapter 11Advanced Batch FilesLECTURE NOTESCHAPTER OUTLINE TEACHING SUGGESTIONSChapter Overview- Quick review of batch file commands learned inearlier chapters.- Advanced features of these commands will be explained and used.- Will explain the purpose and function of remaining batch file commands and then will use these commands to write sophisticated batch files.- Will refine techniques in working with environment.BATCH FILE COMMANDS- Batch File Commands- Batch file rules.- Has .BAT or .CMD as file extension.- Must be ASCII file.- Must include legitimate commands.- Create generic batch files using replaceable parameters.- Are not case-sensitive.- Can use any command in batch file that can be used on the command line.- Many special batch file commands.- See PowerPoint slides # for list of commands andtheir purposes.- Batch files have a limited vocabulary, syntax, and programming logic.- Limited in kind of programming they can do.- Not as versatile as "real" programming languages.A REVIEW OF THE REM, PAUSE, AND ECHO COMMANDS- Slides 2-5 Chapter Overview duplicated in PowerPoint slides. After completion of lecture, suggest to students that they review Objectives and Outcomes found on first page of chapter as a check to see if they have mastered concepts.SECTION 11.1 (pp. 548-549)- Slides 6-10 Already used ECHO, PAUSE, and REM Stress that batch files are similar to programming (logic) but not as powerful. May find it useful to compare to macros in applications.Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line Page 1Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1Instructor: Prof. Michael P. Harris Chapter 11ITSC 1405 – Intro to PC Operating Systems Advanced BATCH Files- A Review of the REM, PAUSE, and ECHO Commands- REM.- Used to document batch files.- Up to string of 123 characters.- ECHO on - displays but does not execute what follows REM.- Won't display if ECHO is off.- Placing REM in front of a command will disable but not delete that specific line.- Batch file or CONFIG.SYS file willcontinue to execute.- Disables line without deleting it.- PAUSE.- <Ctrl> + C or <Ctrl> + <Break> interrupts program.- Temporarily stops executing batch file.- Will not continue until user presses a key.- Will not do any conditional processing.- ECHO.- Used on command line or in batch file.- Controls printing of messages on screenwhen batch file is run.- ECHO ON - (Default) displays all commands to screen along with output.- Useful when tracking operation of abatch file- Clutters screen when batch file runs successfully- ECHO OFF - Displays only output of commands to screen.- ECHO <text string> displays text stringto screen.- Precede ECHO OFF with @ and “ECHO OFF” will not appear on the screen.ADVANCED FEATURES OF ECHO AND REM- Advanced Features of ECHO and REM- REM slows processing of a batch file.SECTION 11.2 (p. 549)- Slides 11-15 Document = Explaining the purpose a file serves. Conditional processing = Comparing two items that yields true or false value. - Program can be directed to take action oncevalue is determined. PAUSE command.- Stops execution of batch file itself – not execution of .EXE or .COM program.- If batch file called an external command & OS in middle of executing command – will finish job before exiting batch file.- Discussion Question (1) - What is the function ofthe REM, ECHO, and PAUSE commands?- Discussion Question (2) - What happens in a batch file if ECHO is set to OFF?- Discussion Question (3) - What happens in a batch file if you precede the ECHO OFF switch with the @?SECTION 11.3 (pp. 549-550)- Slides 16-20Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line Page 2Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1Instructor: Prof. Michael P. Harris Chapter 11ITSC 1405 – Intro to PC Operating Systems Advanced BATCH Files- Recognized by OS as command and must be processed.- Replace REM with double colon (::) forfaster processing. - Label - single colon followed by anything.- Using double colon (::) because labels skipped by OS.- With ECHO OFF, messages still come on screen.- Redirecting output to NUL device eliminates standard output messages.- Will not suppress messages like “File not found”.- To generate blank line on screen: - Use ECHO followed by a period (ECHO.).- No space between ECHO and period.- Using <Enter> will not work in batch files.ACTIVITY—USING ECHO AND NUL- Using ECHO and NUL- DATA disk in Drive A, A:\> displayed.- Activity steps.- Use editor to create/save batch file called ONE.BAT press enter only where indicated:: This is a test of a batch file using <Enter> :: different features. <Enter>COPY CAROLYN.FIL BOOK.FIL <Enter><Enter>TYPE BOOK.FIL <Enter>ECHO <Enter>DEL BOOK.FIL <Enter>COPY NO.FIL BOOK.FIL <Enter>- Close Editor and key in TYPE ONE.BAT - Key in: ONE- Edit/save ONE.BAT so it looks as follows:@ECHO OFF:: This is a test of a batch file using :: different features COPY CAROLYN.FIL BOOK.FIL > NUL Double colon provides faster processing.- Discussion Question (4) - What is a NUL device?Why would you
View Full Document