Training
Certifications
Books
Special Offers
Community




 
Microsoft® Windows® Script Host 2.0 Developer's Guide
Author Gunter Born
Pages 528
Disk 1 Companion CD(s)
Level Intermediate
Published 08/16/2000
ISBN 9780735609310
ISBN-10 0-7356-0931-4
Price(USD) $49.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 

Table of Contents


Introduction xv
PART I   INTRODUCTION TO THE WORLD OF SCRIPT PROGRAMMING  
Chapter 1   Introduction to Windows Script Host 3
    What You Can Do with WSH Scripts 4
        A Few Remarks About VBScript and JScript 5
    Upgrading to WSH 2 5
    Creating and Using Scripts 7
        Creating Your First Script in VBScript 7
        Creating the Same Script in JScript 9
        Executing WSH Scripts 10
        Submitting Arguments to a Script 14
        The New .wsf File Format 19
        Including External Files 20
        Using Type Libraries 20
        Debugging Features 21
Chapter 2   Development Tools and Techniques 23
    Creating Scripts 23
        Using Script Templates 24
    Editing Scripts 26
        Invoking Script Editors 26
    Installing and Uninstalling ActiveX Controls 34
        Registering a Control 34
        Uninstalling a Control 35
    Debugging Scripts 36
        Tracing Your Programs 37
Chapter 3   Introduction to Programming with Objects 45
    Objects 45
        A Simple Object 46
        The Object Model 46
        Collections 47
        Methods 48
        A Practical Example 49
    Available Objects 49
        Getting Information About Objects, Methods, and Properties 50
Chapter 4    Introduction to VBScript 51
    Basic Features 51
        Statements, Continued Lines, and Comments 51
        Constants and Variables 54
        Operators 63
        Control Structures 67
        Loops 69
        Functions and Procedures 71
    Advanced Features 80
        Error Handling 80
        Regular Expressions (in VBScript 5.0 and Later) 82
        Classes (in VBScript 5.0) 85
        Using the With Statement (in VBScript 5.0) 89
Chapter 5   Introduction to JScript 91
    What Is JScript? 91
    The Structure of a JScript Program 92
        Comments 93
        Statements 93
        Constants 94
        Variables 94
        Operators 99
        Control Structures 104
        if Statement 104
        Conditional Operator 105
        for Loop 105
        for...in Loop 107
        while Loop 107
        do...while Loop 108
        switch Statement 109
        break and continue Keywords 110
    Functions and Objects 110
        User-Defined Functions 110
        Built-In Functions 111
        Objects 111
        Arrays 112
PART II  INTERACTIVE SCRIPTING  
Chapter 6   Creating Simple Dialog Boxes in WSH 117
    Using the Echo Method 117
        Using Echo in VBScript 118
        Using Echo in the Command Prompt Window 119
        Using Echo in JScript 120
        Using a Line Feed with Echo 121
    Using the MsgBox Function in VBScript 122
        Defining the Icon and Buttons in a Dialog Box 125
        Setting the Focus on a Button 127
        Determining Which Button Was Used to Close a Dialog Box 128
        Example: A Welcome Login Message in VBScript 130
    Using the Popup Method 134
        Using Popup in VBScript 137
Chapter 7   Working with WSH Objects 141
    Using the WScript Object 141
        Retrieving WSH and Script Properties 142
        Retrieving Language Engine Properties 145
        Accessing Script Arguments 147
    Accessing Environment 152
        Accessing Environment Variables in a Script 152
    Creating and Releasing Objects 165
        CreateObject vs. GetObject 167
        Using DisconnectObject 168
    Launching Other Programs from a Script 170
        Launching Notepad from VBScript 173
        Launching Calculator from JScript 174
        Paths Containing Blanks 175
        The Quit Method 176
Chapter 8   Retrieving User Input in WSH Scripts 183
    Invoking an Input Dialog Box in VBScript 183
    Invoking an Input Dialog Box in JScript 186
        A WSH 2 Solution: Combining VBScript and JScript 186
Chapter 9   Working with Forms 195
    Using Internet Explorer to Create an About Dialog Box 195
        Using the showModalDialog Method to Display an HTML File 196
        Displaying the About Dialog Box Using VBScript 199
        Displaying the About Dialog Box Using JScript 201
    Using Internet Explorer and WSH to Create a Form 202
        HTML Code for the Form 202
        Displaying the Form 203
        A JScript WSH Script for Displaying the Form 207
        Displaying a File Selection Dialog Box 209
Part III  POWER SCRIPTING  
Chapter 10  Creating Shortcuts 225
    Shortcut Basics 225
        Using the CreateShortcut Method 226
    Shortcuts: Beyond the Basics 231
        Using the SpecialFolders Object 231
        Creating a Shortcut on the Desktop 238
        Creating a Shortcut on the Start Menu 242
        Creating a Shortcut Using Arguments 248
        Reading Shortcut Properties 253
        Updating a Shortcut 259
        Creating a Shortcut to a Web Site 263
Chapter 11  Using Advanced WSH Features 267
    Retrieving the User, Domain, or Computer Name 267
        The JScript Implementation 269
    Connecting to a Network Printer 270
        Printer Mapping Using AddWindowsPrinterConnection 271
        Printer Mapping Using AddPrinterConnection 272
        Removing a Printer Mapping 276
        Listing All Mapped Printers 278
        Setting the DefaultPrinter 279
    Mapping Network Drives 281
        The JScript Implementation 284
        Logon Scripts 286
    Accessing the Windows Registry 286
        Accessing the Registry in WSH 288
        Accessing the Registry in VBScript 290
        Run-Time Error Handling for Registry Access 293
        Checking the Existence of a Key 296
        Techniques for Registry Access in WSH 299
        Enumerating Registry Keys and Values 305
        Accessing the Registry Remotely 307
        Changing the Windows 98 Installation Path 309
        Hiding the Last User Name at Logon 311
        Retrieving the Workgroup Name in Windows 98 312
Chapter 12   Using File System and I/O Commands 317
    The FileSystemObject Object Model 317
        Creating a FileSystemObject Object 318
        Methods of the FileSystemObject Object 319
    Accessing Drives 320
        Listing All Drives on a Machine 320
        Showing Drive Properties 325
    Accessing Files and Folders 331
        Listing All Subfolders in a Folder 332
        Creating, Moving, Renaming, and Deleting Folders 335
        Listing All Files in a Folder 343
        Retrieving File Attributes and Dates 347
        Copying and Deleting Files 355
        Backing Up Folders 359
    Accessing Text Files 365
        Reading from a Text File 365
        Pitfalls of Using Dialog Boxes and Browser Windows to View Text Files 368
        Writing to a Text File 376
        Appending New Text to an Existing File 380
        Replacing Text in a File 382
    Using the Browse For Folder Dialog Box 385
        Using BrowseForFolder to Select Folders 386
Chapter 13   Controlling Windows and Applications from Scripts 397
    Delaying Script Execution 397
        Using the Sleep Method to Reduce the CPU Load 398
        Using a Delay to Solve a Problem with Asynchronous Processes 399
    Activating an Application Using the AppActivate Method 401
        Pitfalls of Using the AppActivate Method 404
    Using the SendKeys Method to Simulate Keystrokes 406
        Using SendKeys in WSH 2 406
         Customizing Windows Using Logon Scripts 413
        Setting Up a LogonScript 413
        Using Global Logon and Logoff Scripts 415
        Using Startup and Shutdown Scripts 416
Chapter 14   Programming Techniques and Tips 419
    Run-Time Errors 419
        Handling Run-Time Errors in VBScript 419
        Handling Run-Time Errors in JScript 420
        Paths and Dates 421
        Getting the Script’s Path 421
        Getting the Current Directory 422
        Setting the Default Folder 423
        Getting the Current Drive Name 423
        Calculating Date Differences 424
    Long Filenames, the At Command, and System Calls 425
        Using the Windows NT Scheduler to Execute WSH Scripts 425
        Using Long Filenames in Scripts 425
        Using the Run Method to Execute System Calls 426
        Locking a Windows 2000 Workstation 429
        Invoking the Copy Disk Dialog Box 430
        Invoking the Format Dialog Box 431
        Invoking the Screen Saver Property Page 432
        Calling Control Panel Modules 432
        Using the Run Method to Handle Network Mappings 434
    User Dialog Boxes and Output 434
        Using Tabs and Line Feeds 434
        Displaying Console Input and Output 435
        Writing to a Line and Reading from It 437
        Piping Program Output 439
        Using Files for Streaming 440
        Logging Script Output 443
         File Handling 447
        Checking Whether a File or Folder Exists 447
        Checking Whether a Folder is Empty 448
        Checking Whether an Access Database Is in Use 448
        Copying a File 449
        Renaming a File orFolder 450
        Searching for a File 452
        Listing All Shortcut Files 452
    Playing Sound 454
        Using Internet Explorer to Play Sound 455
    The Windows Shell 457
        Testing the Shell Version 458
        Arranging the Desktop Windows 459
        Opening Folder Windows 461
        Accessing Windows Shell Dialog Boxes 462
    Calling a DUN Connection 465
PART IV  APPENDIXES  
APPENDIX A  WSH Resources on the Internet 469
APPENDIX B  Script Security 471
    Partially Disabling WSH 471
    Preventing Automatic Execution of WSH Scripts 472
    Security Settings for WSH Scripts 475
    Concluding Remarks 479
Index 481




Top of Page


Last Updated: Saturday, July 7, 2001