Introduction |
|
xv | |
|
PART I Introducing the WSH and VBScript |
|
|
1 | (62) |
|
Getting Started with the Wsh and Vbscript |
|
|
3 | (32) |
|
Project Preview: The Knock Knock Game |
|
|
4 | (1) |
|
|
5 | (14) |
|
|
6 | (1) |
|
Selecting a WSH Script Execution Host |
|
|
6 | (1) |
|
Introducing the WSH Core Object Model |
|
|
7 | (1) |
|
How Does the WSH Compare to Windows Shell Scripting? |
|
|
8 | (1) |
|
Understanding How the Windows Shell Works |
|
|
9 | (3) |
|
|
12 | (1) |
|
Operating System Compatibility |
|
|
13 | (1) |
|
|
14 | (1) |
|
How Does It Work with VBScript? |
|
|
14 | (4) |
|
What Other Scripting Languages Does the WSH Support? |
|
|
18 | (1) |
|
|
19 | (7) |
|
|
20 | (1) |
|
|
21 | (1) |
|
VBScript's Cousins: Visual Basic and VBA |
|
|
22 | (4) |
|
Microsoft Scripting Technologies Web Page |
|
|
26 | (2) |
|
Back to the Knock Knock Game |
|
|
28 | (5) |
|
|
28 | (4) |
|
|
32 | (1) |
|
|
33 | (2) |
|
Overview of the Windows Script Host |
|
|
35 | (28) |
|
Project Preview: The Rock, Paper, and Scissors Game |
|
|
36 | (1) |
|
A Detailed Examination of WSH Components |
|
|
36 | (15) |
|
|
37 | (2) |
|
WSH Objects and Their Properties and Methods |
|
|
39 | (12) |
|
Configuring WSH Execution Hosts |
|
|
51 | (7) |
|
Configuring WScript and CScript Command-Line Execution |
|
|
51 | (2) |
|
Configuring WScript Desktop Execution |
|
|
53 | (1) |
|
Overriding Command-Line Host Execution Settings |
|
|
54 | (2) |
|
Customizing WScript Settings for Individual Desktop Scripts |
|
|
56 | (2) |
|
Back to the Rock, Paper, and Scissors Game |
|
|
58 | (4) |
|
|
58 | (3) |
|
|
61 | (1) |
|
|
62 | (1) |
|
PART II Learning VBScript & WSH Scripting |
|
|
63 | (168) |
|
|
65 | (36) |
|
Project Preview: The Math Game |
|
|
66 | (2) |
|
|
68 | (1) |
|
|
68 | (5) |
|
|
70 | (1) |
|
|
70 | (3) |
|
Mastering the VBScript Object Model |
|
|
73 | (1) |
|
Working with VBScript Run-Time Objects |
|
|
74 | (5) |
|
|
75 | (2) |
|
|
77 | (2) |
|
Using VBScript Run-Time Objects in Your Scripts |
|
|
79 | (2) |
|
Examining Built-in VBScript Functions |
|
|
81 | (2) |
|
Demo: The Square Root Calculator |
|
|
81 | (1) |
|
Demo: A New and Improved Square Root Calculator |
|
|
82 | (1) |
|
|
83 | (6) |
|
The WScript's Echo() Method |
|
|
84 | (1) |
|
The WshShell Object's Popup() Method |
|
|
84 | (2) |
|
The VBScript InputBox() Function |
|
|
86 | (1) |
|
The VBScript MsgBox() Function |
|
|
87 | (2) |
|
|
89 | (10) |
|
A Quick Overview of the WshShell SendKeys() Method |
|
|
89 | (3) |
|
|
92 | (4) |
|
|
96 | (3) |
|
|
99 | (2) |
|
Constants, Variables, and Arrays |
|
|
101 | (44) |
|
Project Preview: The Story of Captain Adventure |
|
|
101 | (2) |
|
Understanding How Scripts View Data |
|
|
103 | (1) |
|
Working with Data That Never Changes |
|
|
104 | (7) |
|
Assigning Data to Constants |
|
|
104 | (3) |
|
VBScript Run-Time Constants |
|
|
107 | (4) |
|
Storing Data That Changes During Script Execution |
|
|
111 | (13) |
|
|
111 | (1) |
|
|
112 | (3) |
|
|
115 | (1) |
|
|
116 | (1) |
|
Modifying Variable Values with Expressions |
|
|
117 | (4) |
|
Using the WSH to Work with Environment Variables |
|
|
121 | (3) |
|
Working with Collections of Related Data |
|
|
124 | (11) |
|
|
125 | (1) |
|
Multiple-Dimension Arrays |
|
|
126 | (1) |
|
Processing Array Contents |
|
|
127 | (2) |
|
Getting a Handle on the Size of Your Arrays |
|
|
129 | (1) |
|
|
130 | (3) |
|
|
133 | (2) |
|
|
135 | (1) |
|
Processing Data Passed to a Script at Run-Time |
|
|
135 | (2) |
|
Passing Arguments to Scripts |
|
|
135 | (1) |
|
Designing Scripts That Accept Argument Input |
|
|
136 | (1) |
|
Back to the Story of Captain Adventure |
|
|
137 | (7) |
|
|
138 | (4) |
|
|
142 | (2) |
|
|
144 | (1) |
|
|
145 | (28) |
|
Project Preview: The Star Trek Quiz Game |
|
|
145 | (2) |
|
|
147 | (14) |
|
|
148 | (10) |
|
The Select Case Statement |
|
|
158 | (3) |
|
Performing More Complex Tests with VBScript Operators |
|
|
161 | (1) |
|
Back to the Star Trek Quiz Game |
|
|
162 | (10) |
|
|
163 | (6) |
|
The Fully Assembled Script |
|
|
169 | (3) |
|
|
172 | (1) |
|
Processing Collections of Data |
|
|
173 | (30) |
|
Project Preview: The Guess a Number Game |
|
|
173 | (2) |
|
Adding Looping Logic to Scripts |
|
|
175 | (10) |
|
The For . . . Next Statement |
|
|
175 | (3) |
|
The For Each . . . Next Statement |
|
|
178 | (2) |
|
|
180 | (3) |
|
|
183 | (1) |
|
|
184 | (1) |
|
Back to the Guess a Number Game |
|
|
185 | (16) |
|
|
185 | (4) |
|
|
189 | (2) |
|
Creating Shortcuts for Your Game |
|
|
191 | (9) |
|
A Complete Shortcut Script |
|
|
200 | (1) |
|
|
201 | (2) |
|
Using Procedures to Organize Scripts |
|
|
203 | (28) |
|
Project Preview: The BlackJack Lite Game |
|
|
203 | (2) |
|
Improving Script Design with Procedures |
|
|
205 | (9) |
|
|
206 | (1) |
|
Creating Custom Functions |
|
|
207 | (1) |
|
Improving Script Manageability |
|
|
208 | (1) |
|
|
209 | (1) |
|
The Guess a Number Game Revisited |
|
|
210 | (4) |
|
Working with Built-In VBScript Functions |
|
|
214 | (1) |
|
Limiting Variables Scope with Procedures |
|
|
214 | (2) |
|
Back to the BlackJack Lite Game |
|
|
216 | (14) |
|
|
216 | (9) |
|
|
225 | (5) |
|
|
230 | (1) |
|
|
231 | (200) |
|
Storing and Retrieving Data |
|
|
233 | (44) |
|
Project Preview: The Lucky Lottery Number Picker |
|
|
233 | (2) |
|
Working with the Windows File System |
|
|
235 | (3) |
|
Opening and Closing Files |
|
|
238 | (4) |
|
|
242 | (3) |
|
|
242 | (1) |
|
|
243 | (1) |
|
|
244 | (1) |
|
|
245 | (3) |
|
|
246 | (1) |
|
Reading Files Character by Character |
|
|
247 | (1) |
|
Reading a File All at Once |
|
|
247 | (1) |
|
Managing Files and Folders |
|
|
248 | (6) |
|
Copying, Moving, and Deleting Files |
|
|
249 | (1) |
|
Copying One or More Files |
|
|
250 | (1) |
|
|
250 | (1) |
|
Deleting One or More Files |
|
|
251 | (1) |
|
|
251 | (1) |
|
|
251 | (1) |
|
|
252 | (1) |
|
|
252 | (2) |
|
Storing Script Configuration Settings in External Files |
|
|
254 | (3) |
|
|
254 | (1) |
|
|
254 | (3) |
|
Back to the Lucky Lottery Number Picker |
|
|
257 | (19) |
|
|
258 | (10) |
|
|
268 | (8) |
|
|
276 | (1) |
|
|
277 | (42) |
|
Project Preview: The Hangman Game |
|
|
277 | (2) |
|
Understanding VBScript Errors |
|
|
279 | (7) |
|
Understanding Error Messages |
|
|
280 | (1) |
|
|
281 | (2) |
|
|
283 | (2) |
|
Preventing Logical Errors |
|
|
285 | (1) |
|
|
286 | (5) |
|
|
286 | (1) |
|
|
287 | (1) |
|
|
288 | (3) |
|
|
291 | (2) |
|
Creating a Custom Log File |
|
|
291 | (1) |
|
Recording an Error Message in the Application Event Log |
|
|
292 | (1) |
|
|
293 | (24) |
|
|
294 | (14) |
|
|
308 | (9) |
|
|
317 | (2) |
|
Using the Windows Registry to Configure Script Settings |
|
|
319 | (32) |
|
Project Preview: Part 2 of the Hangman Game |
|
|
319 | (2) |
|
Introducing the Windows Registry |
|
|
321 | (5) |
|
How Is the Registry Organized? |
|
|
322 | (1) |
|
Understanding How Data Is Stored in the Registry |
|
|
323 | (3) |
|
Accessing Registry Keys and Values |
|
|
326 | (1) |
|
Creating a Key and Value to Store Script Settings |
|
|
326 | (3) |
|
Creating or Modifying Registry Keys and Values |
|
|
326 | (1) |
|
Accessing Information Stored in the Registry |
|
|
327 | (1) |
|
|
327 | (1) |
|
Retrieving System Information Stored in the Registry |
|
|
327 | (2) |
|
Back to Part 2 of the Hangman Game |
|
|
329 | (20) |
|
Creating the Setup Script |
|
|
330 | (3) |
|
Updating the Hangman Game |
|
|
333 | (16) |
|
|
349 | (2) |
|
Working with Built-In Vbscript Objects |
|
|
351 | (46) |
|
Project Preview: The Tic-Tac-Toe Game |
|
|
351 | (2) |
|
Leveraging VBScript's Built-In Collection of Objects |
|
|
353 | (3) |
|
Built-In Object Properties |
|
|
355 | (1) |
|
|
355 | (1) |
|
|
356 | (6) |
|
|
356 | (1) |
|
Defining Object Properties and Methods |
|
|
357 | (1) |
|
Creating Event Procedures |
|
|
358 | (4) |
|
Working with the Err Object |
|
|
362 | (1) |
|
Working with Regular Expressions |
|
|
362 | (6) |
|
Replacing Matching Patterns |
|
|
363 | (3) |
|
Testing for Matching Patterns |
|
|
366 | (1) |
|
Creating Matches Collections |
|
|
367 | (1) |
|
Back to the Tic-Tac-Toe Game |
|
|
368 | (27) |
|
|
369 | (14) |
|
|
383 | (12) |
|
|
395 | (2) |
|
Combining Different Scripting Languages |
|
|
397 | (34) |
|
Project Preview: The VBScript Game Console |
|
|
397 | (2) |
|
Introducing Windows Script Files |
|
|
399 | (8) |
|
Examining WSH Supported XML Tags |
|
|
400 | (1) |
|
|
400 | (1) |
|
|
401 | (1) |
|
The <comment> </comment> Tags |
|
|
402 | (1) |
|
|
402 | (2) |
|
The <package> </package> Tags |
|
|
404 | (1) |
|
The <resource> </resource> Tags |
|
|
405 | (1) |
|
The <script> </script> Tags |
|
|
405 | (2) |
|
Executing Your Windows Script Files |
|
|
407 | (1) |
|
Back to the VBScript Game Console |
|
|
407 | (23) |
|
|
407 | (1) |
|
Using XML to Outline the Script's Structure |
|
|
408 | (1) |
|
Writing the First JScript |
|
|
409 | (2) |
|
Developing the VBScript Game Console |
|
|
411 | (9) |
|
Writing the Second JScript |
|
|
420 | (1) |
|
|
420 | (10) |
|
|
430 | (1) |
|
|
431 | (2) |
|
Appendix A WSH Administrative Scripting |
|
|
433 | (34) |
|
|
434 | (4) |
|
Configuring the Desktop Background |
|
|
434 | (2) |
|
Configuring the Screen Saver |
|
|
436 | (2) |
|
|
438 | (3) |
|
|
438 | (2) |
|
Disconnecting Mapped Drives |
|
|
440 | (1) |
|
|
441 | (3) |
|
Connecting to a Network Printer |
|
|
441 | (2) |
|
Disconnecting from a Network Printer |
|
|
443 | (1) |
|
|
444 | (4) |
|
|
444 | (2) |
|
User Account Administration |
|
|
446 | (2) |
|
Scheduling the Execution of Administrative Scripts |
|
|
448 | (5) |
|
|
448 | (2) |
|
|
450 | (1) |
|
Creating a Master Scheduling Script |
|
|
451 | (2) |
|
|
453 | (4) |
|
|
453 | (2) |
|
Automating the Disk Defrag Process |
|
|
455 | (2) |
|
Integrating VBScript with Other Applications |
|
|
457 | (10) |
|
Automating Microsoft Word Reports Generation |
|
|
457 | (4) |
|
Automating the Creation of Microsoft Excel Spreadsheets |
|
|
461 | (3) |
|
Automating the Execution of Third-Party Applications |
|
|
464 | (3) |
|
Appendix B Built-In VBScript Functions |
|
|
467 | (6) |
|
|
467 | (6) |
|
Appendix C What's on the Companion Web Site? |
|
|
473 | (8) |
|
|
473 | (4) |
|
|
477 | (4) |
|
|
477 | (1) |
|
|
478 | (1) |
|
|
479 | (2) |
|
|
481 | (6) |
|
|
481 | (1) |
|
Locating WSH and VBScript Resources Online |
|
|
482 | (5) |
Index |
|
487 | |