Introduction |
|
xvii | |
CHAPTER 1 Introducing Windows Shell Scripting |
|
1 | (24) |
|
Project Preview: The Knock Knock Joke |
|
|
2 | (2) |
|
Overview of Windows Shell Scripting |
|
|
4 | (3) |
|
What Can Shell Scripts Do? |
|
|
6 | (1) |
|
Supported Microsoft Operating Systems |
|
|
7 | (1) |
|
Alternatives to Windows Shell Scripting |
|
|
7 | (3) |
|
|
7 | (3) |
|
Third-Party Scripting Languages |
|
|
10 | (1) |
|
Understanding the Windows Shell |
|
|
10 | (3) |
|
Assembling Your First Windows Shell Script |
|
|
13 | (2) |
|
Creating a Scripting Environment |
|
|
15 | (2) |
|
Back to the Knock Knock Joke |
|
|
17 | (7) |
|
|
17 | (5) |
|
|
22 | (2) |
|
|
24 | (1) |
CHAPTER 2 Interacting with the Windows Shell |
|
25 | (32) |
|
Project Preview: The Unpredictable Command Prompt |
|
|
26 | (1) |
|
Command Shell Command Syntax |
|
|
27 | (2) |
|
Starting Windows Shell Sessions |
|
|
29 | (5) |
|
Working with the CMD Command |
|
|
30 | (2) |
|
Working with the START Command |
|
|
32 | (2) |
|
Internal vs. External Commands |
|
|
34 | (10) |
|
How Windows Locates Commands |
|
|
35 | (1) |
|
|
36 | (3) |
|
Other Useful Windows Commands |
|
|
39 | (5) |
|
Customizing the Windows Command Console |
|
|
44 | (4) |
|
|
44 | (4) |
|
Back to the Unpredictable Command Prompt |
|
|
48 | (7) |
|
|
48 | (5) |
|
|
53 | (2) |
|
|
55 | (2) |
CHAPTER 3 Windows Shell Scripting Basics |
|
57 | (30) |
|
Project Preview: The Fortune Teller Game |
|
|
58 | (1) |
|
|
59 | (4) |
|
Documenting Your Scripts with Comments |
|
|
60 | (1) |
|
Creating a Script Template |
|
|
61 | (2) |
|
Mastering Command Redirection |
|
|
63 | (6) |
|
Examining Data Input and Output |
|
|
64 | (1) |
|
Using One Command's Output as Another Command's Input |
|
|
65 | (1) |
|
|
66 | (2) |
|
|
68 | (1) |
|
Conditional Command Execution |
|
|
69 | (1) |
|
Chaining Two Commands Together |
|
|
69 | (1) |
|
Setting Up Conditional Command Execution |
|
|
69 | (1) |
|
|
70 | (1) |
|
Back to the Fortune Teller Game |
|
|
70 | (15) |
|
|
71 | (1) |
|
Establishing the Execution Environment |
|
|
71 | (1) |
|
Creating a Welcome Screen |
|
|
72 | (1) |
|
|
73 | (1) |
|
Collecting the Player's Question |
|
|
74 | (3) |
|
|
77 | (1) |
|
Generating Random Answers |
|
|
77 | (1) |
|
Displaying the Fortune Teller's Prediction |
|
|
78 | (1) |
|
|
79 | (1) |
|
|
79 | (6) |
|
|
85 | (2) |
CHAPTER 4 Storing and Retrieving Information in Variables |
|
87 | (36) |
|
Project Preview: The Story of Buzz the Wonder Dog |
|
|
88 | (2) |
|
Passing Data to Scripts at Execution Time |
|
|
90 | (3) |
|
Handling Large Numbers of Arguments |
|
|
92 | (1) |
|
Handling Arguments That Include Blank Spaces |
|
|
93 | (1) |
|
|
93 | (12) |
|
Accessing Environment Variables |
|
|
94 | (4) |
|
Creating, Modifying, and Deleting Script Variables |
|
|
98 | (7) |
|
Back to "The Story of Buzz the Wonder Dog" |
|
|
105 | (17) |
|
|
105 | (1) |
|
Configuring the Windows Command Console |
|
|
105 | (1) |
|
Building the Welcome Screen |
|
|
106 | (1) |
|
Providing the Reader with Instructions |
|
|
107 | (1) |
|
Collecting Key Story Elements from the Reader |
|
|
108 | (1) |
|
Using Variable Substitution to Write the Story |
|
|
109 | (2) |
|
|
111 | (11) |
|
|
122 | (1) |
CHAPTER 5 Applying Conditional Logic |
|
123 | (32) |
|
Project Preview: The Guess a Number Game |
|
|
124 | (2) |
|
Applying Conditional Logic to Control Script Execution |
|
|
126 | (13) |
|
Working with the IF Statement |
|
|
126 | (3) |
|
Providing for an Alternative Course of Action |
|
|
129 | (1) |
|
Determining Whether a Variable Already Exists |
|
|
129 | (1) |
|
Keeping an Eye Out for Errors |
|
|
130 | (2) |
|
Checking the Windows Shell Version |
|
|
132 | (1) |
|
Looking for Files and Folders |
|
|
133 | (3) |
|
Reversing the Logic of Conditional Tests |
|
|
136 | (3) |
|
Building Multi-Line IF Statements |
|
|
139 | (1) |
|
Creating Advanced Conditional Logic Tests |
|
|
140 | (2) |
|
Performing Different Kinds of Comparisons |
|
|
142 | (1) |
|
Back to the Guess a Number Game |
|
|
143 | (11) |
|
|
143 | (6) |
|
|
149 | (5) |
|
|
154 | (1) |
CHAPTER 6 Creating Loops to Process Collections of Data |
|
155 | (46) |
|
Project Preview: The Six-Million-Dollar Quiz |
|
|
156 | (2) |
|
|
158 | (16) |
|
Looping Through String Contents |
|
|
160 | (2) |
|
Looping Through Command Output |
|
|
162 | (2) |
|
Processing Collections of Files |
|
|
164 | (2) |
|
Processing Collections of Folders |
|
|
166 | (3) |
|
|
169 | (3) |
|
Iterating a Specified Number of Times |
|
|
172 | (2) |
|
Back to the Six-Million-Dollar Quiz |
|
|
174 | (26) |
|
|
174 | (1) |
|
|
175 | (9) |
|
|
184 | (16) |
|
|
200 | (1) |
CHAPTER 7 Creating Procedures and Subroutines |
|
201 | (40) |
|
Project Preview: The Rock, Paper, Scissors Game |
|
|
202 | (2) |
|
Reorganizing Your Windows Shell Scripts |
|
|
204 | (4) |
|
|
204 | (1) |
|
|
204 | (4) |
|
Improving Script Organization with Procedures |
|
|
208 | (10) |
|
Setting Up Internal Procedures |
|
|
208 | (4) |
|
Creating External Procedures |
|
|
212 | (4) |
|
Using Procedures to Localize Variable Access |
|
|
216 | (1) |
|
Tunneling Data Out of Your Procedures |
|
|
217 | (1) |
|
Back to the Rock, Paper, Scissors Game |
|
|
218 | (21) |
|
Using a Flowchart as a Script Development Tool |
|
|
218 | (3) |
|
Translating Flowchart Design into Script Requirements |
|
|
221 | (9) |
|
|
230 | (9) |
|
|
239 | (2) |
CHAPTER 8 Debugging and Error Handling |
|
241 | (56) |
|
Project Preview: The Tic-Tac-Toe Game |
|
|
242 | (2) |
|
Understanding Windows Shell Script Errors |
|
|
244 | (2) |
|
|
245 | (1) |
|
|
245 | (1) |
|
|
246 | (1) |
|
Examining Windows Shell Script Error Messages |
|
|
246 | (4) |
|
|
246 | (3) |
|
|
249 | (1) |
|
|
249 | (1) |
|
Examining Different Ways of Dealing with Errors |
|
|
250 | (9) |
|
|
250 | (1) |
|
Tracing Logic Flow within Scripts |
|
|
251 | (3) |
|
|
254 | (2) |
|
|
256 | (1) |
|
Displaying Error Messages |
|
|
257 | (2) |
|
Creating Scripts That Return a Custom Exit Code |
|
|
259 | (1) |
|
Other Things to Look Out For |
|
|
260 | (4) |
|
|
261 | (1) |
|
Dealing with Scripts That Are Difficult to Read and Understand |
|
|
261 | (1) |
|
Working with Windows Commands |
|
|
262 | (1) |
|
Managing Arguments and Variables |
|
|
262 | (1) |
|
Handling Files and Folders |
|
|
263 | (1) |
|
Taking Precautions with Loops |
|
|
263 | (1) |
|
Keeping Procedures Straight |
|
|
264 | (1) |
|
Back to the Tic-Tac-Toe Game |
|
|
264 | (30) |
|
|
264 | (16) |
|
|
280 | (14) |
|
|
294 | (3) |
APPENDIX A Windows Shell Scripting Administrative Scripts |
|
297 | (44) |
|
Working with Network Drives |
|
|
298 | (7) |
|
|
305 | (7) |
|
|
312 | (3) |
|
Scheduling Script Execution |
|
|
315 | (9) |
|
|
315 | (5) |
|
The Scheduled Task Wizard |
|
|
320 | (1) |
|
Starting the Task Scheduler Service |
|
|
321 | (1) |
|
Running the Scheduled Task Wizard |
|
|
321 | (3) |
|
|
324 | (6) |
|
Adding a Graphical Interface |
|
|
330 | (4) |
|
Working with Third-Party Applications |
|
|
334 | (7) |
APPENDIX B What's on the CD-ROM? |
|
341 | (8) |
|
Windows Shell Scripting Examples |
|
|
342 | (1) |
|
|
343 | (6) |
|
|
344 | (1) |
|
|
345 | (4) |
APPENDIX C What Newt? |
|
349 | (6) |
|
|
350 | (1) |
|
Locating Internet Resources |
|
|
351 | (4) |
Glossary |
|
355 | (10) |
Index |
|
365 | |