Ch 101 Introduction to Batch Files. Ch 102 Overview Will learn to create batch files to automate a sequence of commands to accomplish various tasks.

Slides:



Advertisements
Similar presentations
A batch file is a file that contains a number of DOS commands, each of which could be run individually from the command prompt. By putting them into a.
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Windows XP Basics OVERVIEW Next.
Automating Tasks With Macros
© 2007 The McGraw-Hill Companies, Inc. All rights reserved Working with the Command- Line Interface Chapter 14.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Using the Visual Basic Editor Visual Basic for Applications 1.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
The sequence of folders to a file or folder is called a(n) ________.
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
FILES  A file is a collection of related information  Files are kept in directories on a disk.
Adding Automated Functionality to Office Applications.
Word Lesson 16 Working with Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
Lesson 9 Windows Management
Ch 111 Chapter 11 Advanced Batch Files. Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files.
Or CMD/BATCH.  Title this comand makes the cmd prompt’s title whatever you would like it to be.
Comandos Windows. ASSOC - Displays or modifies file extension associations.
Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Ch 71 Using ATTRIB, SUBST, XCOPY, DOSKEY, and the Text Editor.
Ch11 Getting Started with the Operating System. Ch12 Overview Will discuss the purpose and function of an operating system.
I Can… Define basic file management and related terms Identify levels of a file system Identify and explain ways to view files in Windows OS Explain the.
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
Project 3 File, Document, Folder Management, Windows XP Explorer Windows XP Service Pack 2 Edition Comprehensive Concepts and Techniques.
1 Guide to Novell NetWare 6.0 Network Administration Chapter 12.
Introduction to Shell Script Programming
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that contains an ordered series of commands.
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
Batch File Basics Automate repetitive computer processes Friday, March 12, 2014 Presented by Thomas Redd, STS, Granite School District.
Ch 41 Program Files, Data Files, and Subdirectories.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000.
Linux Operations and Administration
Lesson 11: Looking at Files and Folders what a file or folder is on the computer how to recognize a file or folder on the desktop how to recognize the.
Getting Started Additional information. Important DOS Commands Getting Started dirlists disk directories verdisplays OS version clsclear command prompt.
Operating Systems Concepts 1/e Ruth Watson Chapter 3 Chapter 3 DOS Ruth Watson.
Editors And Debugging Systems Other System Software Text Editors Interactive Debugging Systems UNIT 5 S.Sharmili Priyadarsini.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Project 2 Working on the Windows XP Desktop Windows XP Service Pack 2 Edition Comprehensive Concepts and Techniques.
Lesson 9: Windows Management Ms. Tracy Digital Literacy.
Microsoft Office XP Illustrated Introductory, Enhanced with Programs, Files, and Folders Working.
Lab Assignment 4 Using Batch Files
Ch 91 Pipes, Filters and Redirection. Ch 92 Overview Will use redirection to redirect standard input and standard output.
Chapter Three The UNIX Editors.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
File and Folder CLI Commands 12/24/ Agenda Overview of OS functions and the SHELL Internal v External Commands Command History Making & Modifying.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 3 Windows File Management 1 Morrison / Wells / Ruffolo.
THE C PROGRAMMING ENVIRONMENT. Four parts of C environment  Main menu  Editor status line and edit window  Compiler message window  “Hot Keys” quick.
XP New Perspectives on Microsoft Windows XP Tutorial 2 1 Microsoft Windows XP Working with Files Tutorial 2.
1 Introduction to SQL *Plus Oracle SQL Interface MIS309 Database Systems.
1 Lesson 9 Windows Management Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
MS-DOS is an acronym for MicroSoft Disk Operating System It is a CUI based operating system. It provides user with a command prompt (generally called.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Release Numbers MATLAB is updated regularly
An Introduction to Computers and Visual Basic
An Introduction to Computers and Visual Basic
Microsoft Excel 2003 Illustrated Complete
Command Syntax Chapter 2 Using the DIR Command with
Lesson 9 Windows Management
An Introduction to Computers and Visual Basic
Presentation transcript:

Ch 101 Introduction to Batch Files

Ch 102 Overview Will learn to create batch files to automate a sequence of commands to accomplish various tasks.

Ch 103 Overview The use of batch file subcommands will be discussed and then used with batch commands.

Ch 104 Overview How to halt the execution of a batch file will be explained.

Ch 105 Overview Will write batch files using replaceable parameters.

Ch 106 Overview Learn how batch files can be used from the desktop.

Ch 107 Concepts of Batch and Interactive Processing Batch file: è String together series of commands executed sequentially with one command without human interaction or interruption

Ch 108 Concepts of Batch and Interactive Processing Batch file: è Must be an ASCII file è Created with Edit, COPY CON, text editor, or word processor which has “Save as text file” option è Has.BAT or.CMD extension è Each line in batch file contains only one command

Ch 109 Concepts of Batch and Interactive Processing Why batch files used: è Minimize keystrokes è Automate frequent/consistent procedures è Do not need to interact with computer while batch files are running

Ch 1010 Concepts of Batch and Interactive Processing Batch processing: è Automate frequent/consistent procedures è Batch files can be run at anytime åNo user/computer interaction required

Ch 1011 Concepts of Batch and Interactive Processing Interactive processing: è Also called online or real time mode è User interacts directly with computer è Information processed without delay

Ch 1012 How Batch Files Work The operating system determines if a file is a data file or a program file by its extension.

Ch 1013 How Batch Files Work To locate file, operating system: è Looks internally for command è Using Extension Priority Rules, searches on default drive and directory è Searches search path as set in PATH statement following Priority Rules

Ch 1014 How Batch Files Work Table 10.1 Search Order for Extensions pp

Ch 1015 How Batch Files Work Priority rules are followed if there are files on a disk with the same file name but three different file extensions.

Ch 1016 How Batch Files Work If file not found, get error message: “Filename is not recognized as an internal or external command, operable program, or batch file.”

Ch 1017 How Batch Files Work è A batch file is a program. è Each line in a batch file must contain only one command.

Ch 1018 Using EDIT to Write Batch Files To write a batch file you must use a program that creates ASCII text files.

Ch 1019 Using EDIT to Write Batch Files If a file is readable with the TYPE command, it is an ASCII text file.

Ch 1020 Using EDIT to Write Batch Files Word-processing programs can create text files if they have a nondocument or text mode.

Ch 1021 Using EDIT to Write Batch Files EDIT: è Simple text editor in Command Prompt window è Used to write batch files.

Ch 1022 Using EDIT to Write Batch Files Notepad: è Window’s text editor è Used to write batch files

Ch 1023 Activity—Writing and Executing a Batch File KEY CONCEPTS: è Create batch files with: åEDIT - tool to write batch files åAny text editor or word processor with ASCII output è Batch file extensions -.BAT or.CMD è Execute the batch file the same ways as you do any command

Ch 1024 Writing and Executing a Batch File to Save Keystrokes Batch files can save keystrokes. Examples: DIR/AD DIR/OS and DIR/O-S

Ch 1025 Sometimes easier to use COPY CON instead of EDIT to write simple batch file. Syntax: COPY CON filename Writing and Executing a Batch File to Save Keystrokes

Ch 1026 Drawbacks to using COPY CON: è Cannot correct errors once is pressed è Cannot correct errors in existing files Writing and Executing a Batch File to Save Keystrokes

Ch 1027 è To correct errors need text editor like EDIT. è Nothing is faster than COPY CON. Writing and Executing a Batch File to Save Keystrokes

Ch 1028 KEY CONCEPTS: è Pressing and signals completion è +Z same as pressing è Displaying file with TYPE indicates it is ASCII file è Create one-line batch files è Directories have no size Activity—Writing & Executing a One-Letter Batch File

Ch 1029 Open command line session by: è Clicking icon on Start menu è Clicking shortcut åCan be altered to run in customized way Using Batch Files to Alter Your Command Line Environment

Ch 1030 KEY CONCEPTS: è Created shortcut to open command line session on desktop åCan decide what directory to be in è With /k parameter - include batch file that is executed each time command line session opened åValue limited on floppy åValuable on hard drive Activity - Creating a Batch File to Alter the Command Line Session Environment

Ch 1031 è To execute BOG game took three steps. è Create a batch file to simplify loading an application program. Writing a Batch File to Load Application Program

Ch 1032 KEY CONCEPTS: è Create batch files with: åCOPY CON åAny text editor or word processor with ASCII output (Example: Edit) è Why no conflict between BOG.BAT and BOG.EXE names è How to execute command that requires particular location Activity—Writing a Batch File to Execute BOG Game

Ch 1033 To run a batch file from Windows: è Double-click file name in Windows Explorer/My Computer è Create shortcut for file and place on desktop and click icon Creating Shortcuts for Batch Files on the Desktop

Ch 1034 Some things can be done with shortcut that cannot do in the command line interface. è Click shortcut to execute batch è Can change shortcut icon Creating Shortcuts for Batch Files on the Desktop

Ch 1035 KEY CONCEPTS: è Clicking shortcut executes file è Can change icon so it is more distinctive Activity—Creating a Shortcut on the Desktop

Ch 1036 Where Windows system files reside will vary depending on installation of Windows XP Professional. Batch Files to Run Windows Programs

Ch 1037 Windows “keeps notes” about itself in system environment. è Path stored in environmental variable %Path% è Drive referred to in environment as %SystemDrive% è Directory where system files are located referred to as %SystemRoot% Batch Files to Run Windows Programs

Ch 1038 With Notepad: è Can create batch file that allows you to run program without returning to desktop è Can create log file that adds current date and time to file created with Notepad Batch Files to Run Windows Programs

Ch 1039 Activity—Creating a Batch File to Run Notepad KEY CONCEPTS: è %SYSTEMROOT% ( Environmental variable ) åWindows knows where Windows files are located and substitutes correct name å% signs around name - OS substitutes value for that variable. è Opened Notepad without returning to desktop è Used Notepad to create log file (case sensitive) è Created log file

Ch 1040 Activity—Creating a Batch File to Run Notepad KEY CONCEPTS: è START command: åCan start a program in new window while still executing batch program in previous window åIf title following command is in quotes, will give window that title

Ch 1041 Special Batch File Commands Table 10.2 Batch File Commands pp

Ch 1042 Special Batch File Commands Table 10.2 Batch File Commands pp

Ch 1043 The REM Command REM command (remarks) allows user to place comments in file that are displayed but not executed

Ch 1044 The REM Command REM allows file to be documented: è Gives explanation of the purpose of a program è Can include name of batch file, last time it was updated, and author of batch file

Ch 1045 Activity—Using REM KEY CONCEPTS: è Used Edit to write batch file è Purpose of REM - provide explanatory remarks about the batch file è If line begins with REM - explanatory text follows and no action taken è No more lines in batch file -OS returns to system level

Ch 1046 The ECHO Command ECHO ON command: è Displays command and the command’s output to the screen è Is the default value

Ch 1047 The ECHO Command ECHO OFF command: è Minimizes screen clutter è User turns off display of command then only see command’s output

Ch 1048 The ECHO Command Table 10.3 ECHO ON or OFF p. 512

Ch 1049 Activity—Using ECHO KEY CONCEPTS: è ECHO ON - see remarks and commands è ECHO OFF - output displayed not actual commands OFF suppresses display of ECHO OFF è Purpose of batch files defeated if interaction required by user

Ch 1050 Activity—Using ECHO Table 10.4 Echo On and ECHO Off: A Comparison of Screen Displays p. 516

Ch 1051 The CLS Command CLS command used to clear screen when it becomes full of no longer needed information.

Ch 1052 Activity - Using CLS KEY CONCEPTS: è After ECHO turned off screen cleared

Ch 1053 The PAUSE Command PAUSE command instructs the batch file to stop executing until the user takes some action.

Ch 1054 Activity—Using Pause KEY CONCEPTS: è Batch file “paused” - stopped executing until some action is taken è Pause is not an order

Ch 1055 Stopping a Batch File from Executing To interrupt a batch file during execution: è Press + C è Press +

Ch 1056 Stopping a Batch File from Executing Return to system prompt when batch file interrupted.

Ch 1057 Activity—Quitting a Batch File KEY CONCEPTS: è Results of Pressing + C è Because of speed of computer difficult to ascertain how many lines of batch file read when + C pressed

Ch 1058 Can use fixed or variable parameters with batch files. Replaceable Parameters in Batch Files

Ch 1059 Example of fixed parameter: è DIR A: /W Examples of variable parameter: è TYPE THIS.FIL è TYPE TEST.TXT Replaceable Parameters in Batch Files

Ch 1060 Replaceable Parameters in Batch Files è Batch files can also use replaceable parameters. è Replaceable parameters also called dummy, substitute or positional parameters.

Ch 1061 Replaceable Parameters in Batch Files Can parse batch commands: è Keying in additional information on command line è Dividing computer language into parts that can be made useful to computer

Ch 1062 Replaceable Parameters in Batch Files User supplies markers (place holders) to let batch file know that variable will be keyed in with batch file name.

Ch 1063 Replaceable Parameters in Batch Files The place holder used in batch files is the percent sign (%), followed by a number (0-9).

Ch 1064 Replaceable Parameters in Batch Files è The % sign is a signal to the operating system that a parameter is coming. è The numbers (0-9) indicate what position the parameter is on in the command line.

Ch 1065 Activity—Using Replaceable Parameters KEY CONCEPTS: è Data still on disk when file deleted è To delete data overwrite file with new data è Create generic or “plain wrap” batch file å Supply specific parameter of file name of interest å Supply place (“replaceable parameters”)for name of file å View replaceable parameters as positional parameters  % sign followed by number

Ch 1066 Multiple Replaceable Parameters in Batch Files Many commands used in batch files may require more than one parameter.

Ch 1067 Multiple Replaceable Parameters in Batch File Batch files can have up to 10 replaceable ( positional ) parameters ( %0-%9 ).

Ch 1068 Multiple Replaceable Parameters in Batch Files Example: COPY MYFILE.TXT YOUR.FIL

Ch 1069 Activity—Using Multiple Replaceable Parameters KEY CONCEPTS: è Within batch files parameters do not have to be in order. è Order used on command line å%1 - refers to first position after command not first item on command line

Ch 1070 Activity—Using Multiple Replaceable Parameters Table 10.5 Positional Parameters p. 529

Ch 1071 Activity—Using Multiple Replaceable Parameters KEY CONCEPTS: è Think of them as positional not replaceable parameters è Copy files selectively (all except ones hidden) è Do not use or | in batch files as OS reads them as redirection or pipe symbols

Ch 1072 Activity—Using Multiple Replaceable Parameters NOCOPY CLASS\*.ABC TRIP CLASS Rest of lines executed in order è REM This batch file, NOCOPY.BAT, will hide specified files, è REM then copy all other files from one location to another,

Ch 1073 Activity—Using Multiple Replaceable Parameters è REM then unhide the original files. è ATTRIB +H CLASS\*.ABC è COPY CLASS\*.* TRIP è ATTRIB -H CLASS\*.ABC

Ch 1074 Creating Useful Batch Files Can create commands that are not provided with the operating system.

Ch 1075 Activity—Writing Useful Batch Files KEY CONCEPTS: è Create batch file that will compare file names in directories or on disks è OFF at beginning of batch file - see results of command not REM statements

Ch 1076 Activity—Writing Useful Batch Files Examine each part of command line: DIR /A-D /B /ON %1 > SOURCE.TMP