VBScript Programmer's Reference, Third Edition

Book description

  • Completely updated for Windows Vista and Windows Server 2003 R2, this book is packed with practical examples for today's programmer, Web developer, or system administrator

  • Combines a comprehensive overview of the VBScript technology and associated technologies with sample code at every stage from beginner to advanced user

  • Discusses the general syntax, functions, keywords, style, error handling, and similar language-specific topics and then moves into an expanded reference section covering the object models in detail

  • Presents advanced coverage on Active Directory Service Interfaces (ADSI), PowerShell, security scripting, remote scripting, database scripting, and more

  • Table of contents

    1. Copyright
    2. About the Authors
    3. Credits
    4. Acknowledgments
    5. Introduction
      1. Whom This Book Is For
      2. What This Book Covers
      3. How This Book Is Structured
      4. What You Need to Use This Book
      5. Conventions
      6. Source Code
      7. Errata
      8. p2p.wrox.com
    6. 1. A Quick Introduction to Programming
      1. 1.1. Variables and Data Types
        1. 1.1.1. Using Variables
        2. 1.1.2. Using Comments
        3. 1.1.3. Using Built-in VBScript Functions
        4. 1.1.4. Understanding Syntax Issues
      2. 1.2. Flow Control
        1. 1.2.1. Branching
        2. 1.2.2. Looping
          1. 1.2.2.1. Using the Do...Loop While Loop
          2. 1.2.2.2. Using the For...Next Loop
      3. 1.3. Operators and Operator Precedence
      4. 1.4. Organizing and Reusing Code
        1. 1.4.1. Modularization, Black Boxes, Procedures, and Subprocedures
        2. 1.4.2. Turning Code into a Function
        3. 1.4.3. Advantages to Using Procedures
      5. 1.5. Top-Down versus Event-Driven
        1. 1.5.1. Understanding Top-Down Programming
        2. 1.5.2. Understanding Event-Driven Programming
        3. 1.5.3. How Top-Down and Event-Driven Work Together
        4. 1.5.4. An Event-Driven Code Example
      6. 1.6. Coding Guidelines
        1. 1.6.1. Expect the Unexpected
        2. 1.6.2. Always Favor the Explicit over the Implicit
        3. 1.6.3. Modularize Your Code into Procedures, Modules, Classes, and Components
        4. 1.6.4. Use the "Hungarian" Variable Naming Convention
        5. 1.6.5. Don't Use One Variable for More Than One Job
        6. 1.6.6. Always Lay Out Your Code Properly
        7. 1.6.7. Use Comments to Make Your Code More Clear and Readable, but Don't Overuse Them
      7. 1.7. Summary
    7. 2. What VBScript Is — and Isn't!
      1. 2.1. Windows Script
      2. 2.2. Version Information
      3. 2.3. VBScript Is a Subset of VB
      4. 2.4. VBScript Is a Scripting Language
      5. 2.5. VBScript Is Interpreted at Runtime
        1. 2.5.1. Runtime Compilation — Disadvantages
        2. 2.5.2. Runtime Compilation — Advantages
      6. 2.6. Advantages of Using VBScript
      7. 2.7. Is VBScript Right for You?
      8. 2.8. How VBScript Fits in with the Visual Basic Family
        1. 2.8.1. Visual Basic
        2. 2.8.2. Visual Basic for Applications
        3. 2.8.3. VBScript
        4. 2.8.4. Is VBScript a "Real" Programming Language?
      9. 2.9. What Can You Do with VBScript?
        1. 2.9.1. PowerShell
        2. 2.9.2. Windows Script Host
        3. 2.9.3. Gadgets
        4. 2.9.4. Windows Script Components
        5. 2.9.5. Client-Side Web Scripting
        6. 2.9.6. Server-Side Web Scripting
        7. 2.9.7. Remote Scripting
        8. 2.9.8. HTML Applications
        9. 2.9.9. Add VBScript to Your Applications
      10. 2.10. Tool of the Trade — Tools for VBScript
        1. 2.10.1. Text Editor Listing
      11. 2.11. Summary
    8. 3. Data Types
      1. 3.1. Scripting Languages as Loosely Typed
      2. 3.2. Why Data Types Are Important
      3. 3.3. The Variant: VBScript's Only Data Type
        1. 3.3.1. Testing for and Coercing Subtypes
          1. 3.3.1.1. Automatic Assignment of String Subtype
          2. 3.3.1.2. Coercing String to Long
          3. 3.3.1.3. Hungarian Notation Variable Prefixes
          4. 3.3.1.4. Automatic Assignment of the Date Subtype
          5. 3.3.1.5. The "Is" Functions
        2. 3.3.2. Implicit Type Coercion
        3. 3.3.3. Implicit Type Coercion in Action
          1. 3.3.3.1. Avoiding Trouble with Implicit Type Coercion
          2. 3.3.3.2. Avoiding Trouble with the "&" and "+" Operators
        4. 3.3.4. Empty and Null
        5. 3.3.5. The Object Subtype
        6. 3.3.6. The Error Subtype
      4. 3.4. Arrays as Complex Data Types
        1. 3.4.1. What Is an Array?
        2. 3.4.2. Arrays Have Dimensions
        3. 3.4.3. Array Bounds and Declaring Arrays
        4. 3.4.4. Accessing Arrays with Subscripts
        5. 3.4.5. Looping through Arrays
        6. 3.4.6. Erasing Arrays
        7. 3.4.7. Using VarType() with Arrays
      5. 3.5. Summary
    9. 4. Variables and Procedures
      1. 4.1. Option Explicit
      2. 4.2. Naming Variables
      3. 4.3. Procedures and Functions
        1. 4.3.1. Procedure Syntax
        2. 4.3.2. Function Syntax
        3. 4.3.3. Calling Procedures and Functions
        4. 4.3.4. Optional Arguments
        5. 4.3.5. Exiting a Procedure or Function
      4. 4.4. Variable Scope, Declaration, and Lifetime
        1. 4.4.1. Understanding Variable Scope
        2. 4.4.2. Understanding Variable Declaration
        3. 4.4.3. Variable Lifetime
      5. 4.5. Design Strategies for Scripts and Procedures
        1. 4.5.1. Limiting Code that Reads and Changes Variables
        2. 4.5.2. Breaking Code into Procedures and Functions
        3. 4.5.3. General Tips for Script Design
      6. 4.6. ByRef and ByVal
      7. 4.7. Literals and Named Constants
        1. 4.7.1. What Is a Literal?
        2. 4.7.2. What Is a Named Constant?
        3. 4.7.3. Benefits of Named Constants
        4. 4.7.4. Guidelines for Named Constants
        5. 4.7.5. Built-In VBScript Constants
      8. 4.8. Summary
    10. 5. Control of Flow
      1. 5.1. Branching Constructs
        1. 5.1.1. The "If" Branch
        2. 5.1.2. The "Select Case" Branch
      2. 5.2. Loop Constructs
        1. 5.2.1. For...Next
        2. 5.2.2. For Each...Next
        3. 5.2.3. Do Loop
          1. 5.2.3.1. Executing the Block at Least Once
          2. 5.2.3.2. Testing a Precondition
          3. 5.2.3.3. Choosing Between Until and While
          4. 5.2.3.4. Breaking Out of a Do Loop
        4. 5.2.4. While...Wend
      3. 5.3. Summary
    11. 6. Error Handling and Debugging
      1. 6.1. Types of Errors
        1. 6.1.1. Syntax Errors
        2. 6.1.2. Runtime Errors
          1. 6.1.2.1. Native VBScript Runtime Errors
          2. 6.1.2.2. Non-VBScript Runtime Errors
          3. 6.1.2.3. Errors Related to Option Explicit
        3. 6.1.3. Logic Errors
      2. 6.2. Error Visibility and Context
        1. 6.2.1. Windows Script Host Errors
        2. 6.2.2. Server-Side ASP Errors
        3. 6.2.3. Client-Side VBScript Errors in Internet Explorer
      3. 6.3. Handling Errors
        1. 6.3.1. Using the Err Object
        2. 6.3.2. Using the On Error Statements
          1. 6.3.2.1. Understanding VBScript Error Control
          2. 6.3.2.2. Flipping the Error Handling Switch
          3. 6.3.2.3. Setting Traps for Errors
        3. 6.3.3. Presenting and Logging Errors
        4. 6.3.4. Displaying Server-Side ASP Errors
      4. 6.4. Generating Custom Errors
        1. 6.4.1. Using Err.Raise
        2. 6.4.2. When Not to Use Err.Raise
        3. 6.4.3. When to Generate Custom Errors
      5. 6.5. Debugging
        1. 6.5.1. What Is a Debugger?
        2. 6.5.2. VBScript Debugging Scenarios
        3. 6.5.3. Debugging WSH Scripts with the Microsoft Script Debugger
          1. 6.5.3.1. Downloading and Enabling the Debugger
          2. 6.5.3.2. Running the Debugger
          3. 6.5.3.3. Switch Examples
        4. 6.5.4. Debugging Client-Side Web Scripts with the Microsoft Script Debugger
          1. 6.5.4.1. Enabling the Script Debugger
          2. 6.5.4.2. Activating the Debugger with an Error
          3. 6.5.4.3. Activating the Debugger with the Stop Statement
          4. 6.5.4.4. Activating the Debugger with a Manual Breakpoint
        5. 6.5.5. Debugging ASP with the Microsoft Script Debugger
          1. 6.5.5.1. Enabling ASP Debugging
          2. 6.5.5.2. Activating the Debugger
        6. 6.5.6. Debugging without a Debugger
          1. 6.5.6.1. Using a Global Debug Flag
          2. 6.5.6.2. Outputting Debug Messages
          3. 6.5.6.3. Homemade Assertions
          4. 6.5.6.4. Inserting Temporary Test Code
        7. 6.5.7. Using the Microsoft Script Debugger
          1. 6.5.7.1. Setting Breakpoints
          2. 6.5.7.2. Stepping Through Code
          3. 6.5.7.3. Using the Command Window
          4. 6.5.7.4. Viewing the Call Stack
      6. 6.6. Summary
    12. 7. The Scripting Runtime Objects
      1. 7.1. What Are Runtime Objects?
      2. 7.2. Object Basics
        1. 7.2.1. Creating Objects
        2. 7.2.2. Properties and Methods
        3. 7.2.3. The "With" Keyword
        4. 7.2.4. Objects Can Have Multiple References
        5. 7.2.5. Object Lifetime and Destroying Objects
      3. 7.3. The Dictionary Object
        1. 7.3.1. Overview
        2. 7.3.2. Three Different Ways to Add
        3. 7.3.3. The CompareMode Property
        4. 7.3.4. The Item Property
        5. 7.3.5. The Exists Method
      4. 7.4. The FileSystemObject Library
        1. 7.4.1. Why FileSystemObject?
        2. 7.4.2. Using Collections
        3. 7.4.3. Understanding FileSystemObject
        4. 7.4.4. Creating a Folder
        5. 7.4.5. Copying a File
        6. 7.4.6. Copying a Folder
        7. 7.4.7. Reading a Text File
        8. 7.4.8. Writing to a Text File
      5. 7.5. Summary
    13. 8. Classes in VBScript (Writing Your Own COM Objects)
      1. 8.1. Objects, Classes, and Components
      2. 8.2. The Class Statement
      3. 8.3. Defining Properties
        1. 8.3.1. Private Property Variables
        2. 8.3.2. Property Let
        3. 8.3.3. Property Get
        4. 8.3.4. Property Set
        5. 8.3.5. Making a Property Read-Only
        6. 8.3.6. Making a Property Write-Only
        7. 8.3.7. Public Properties without Property Procedures
      4. 8.4. Defining Methods
      5. 8.5. Class Events
        1. 8.5.1. The Class_Initialize Event
        2. 8.5.2. The Class_Terminate Event
      6. 8.6. Class-Level Constants
      7. 8.7. Building and Using a Sample VBScript Class
      8. 8.8. Summary
    14. 9. Regular Expressions
      1. 9.1. Introduction to Regular Expressions
        1. 9.1.1. Regular Expressions in Action
        2. 9.1.2. Building on Simplicity
      2. 9.2. The RegExp Object
        1. 9.2.1. Global Property
        2. 9.2.2. IgnoreCase Property
        3. 9.2.3. Pattern Property
        4. 9.2.4. Regular Expression Characters
          1. 9.2.4.1. Matching a Whole Class of Characters
          2. 9.2.4.2. Replacing Digits and Everything but Digits
          3. 9.2.4.3. Anchoring and Shorting a Pattern
          4. 9.2.4.4. Specifying a Minimum Number or Range of Matches
          5. 9.2.4.5. Remembered Matches
        5. 9.2.5. Execute Method
        6. 9.2.6. Replace Method
        7. 9.2.7. Backreferencing
        8. 9.2.8. Test Method
      3. 9.3. The Matches Collection
        1. 9.3.1. Matches Properties
        2. 9.3.2. The Match Object
          1. 9.3.2.1. FirstIndex Property
          2. 9.3.2.2. Length Property
          3. 9.3.2.3. Value Property
      4. 9.4. A Few Examples
        1. 9.4.1. Validating Phone Number Input
        2. 9.4.2. Breaking Down URIs
        3. 9.4.3. Testing for HTML Elements
        4. 9.4.4. Matching White Space
        5. 9.4.5. Matching HTML Comment Tags
      5. 9.5. Summary
    15. 10. Client-Side Web Scripting
      1. 10.1. Tools of the Trade
      2. 10.2. The Evolution of Scripting
      3. 10.3. Different Scripting Languages
        1. 10.3.1. JavaScript, JScript, and ECMAScript
        2. 10.3.2. VBScript
      4. 10.4. Responding to Browser Events
        1. 10.4.1. Adding an Event Handler
        2. 10.4.2. Adding an Event Handler That Passes Parameters
        3. 10.4.3. Cancelling Events
        4. 10.4.4. The Order of Things
        5. 10.4.5. Form Validation
        6. 10.4.6. Validating Numerical Input Box Values
        7. 10.4.7. Validating Radio Buttons
        8. 10.4.8. Validating Select Controls and Dates
      5. 10.5. The Document Object Model in Action
        1. 10.5.1. The Window Object
        2. 10.5.2. Collections
      6. 10.6. Summary
    16. 11. Windows Sidebars and Gadgets
      1. 11.1. Gadget Basics
        1. 11.1.1. Gadget Files
        2. 11.1.2. The Manifest File
        3. 11.1.3. Icons
      2. 11.2. Building a Gadget
      3. 11.3. Auto-Refresh a Gadget
      4. 11.4. Packaging the Gadget
      5. 11.5. Summary
    17. 12. Task Scheduler Scripting
      1. 12.1. Working with Task Scheduler
        1. 12.1.1. Using the MMC Snap-in
        2. 12.1.2. Defining and Creating Tasks in Task Scheduler
        3. 12.1.3. Task Scheduler XML Schema
      2. 12.2. Task Scheduler 2.0 Scripting Objects
        1. 12.2.1. Action
          1. 12.2.1.1. Methods
          2. 12.2.1.2. Properties
        2. 12.2.2. ActionCollection
          1. 12.2.2.1. Methods
          2. 12.2.2.2. Properties
        3. 12.2.3. BootTrigger
          1. 12.2.3.1. Methods
          2. 12.2.3.2. Properties
        4. 12.2.4. ComHandlerAction
          1. 12.2.4.1. Methods
          2. 12.2.4.2. Properties
        5. 12.2.5. DailyTrigger
          1. 12.2.5.1. Methods
          2. 12.2.5.2. Properties
        6. 12.2.6. EmailAction
          1. 12.2.6.1. Methods
          2. 12.2.6.2. Properties
        7. 12.2.7. EventTrigger
          1. 12.2.7.1. Methods
          2. 12.2.7.2. Properties
        8. 12.2.8. ExecAction
          1. 12.2.8.1. Methods
          2. 12.2.8.2. Properties
        9. 12.2.9. IdleSettings
          1. 12.2.9.1. Methods
          2. 12.2.9.2. Properties
        10. 12.2.10. IdleTrigger
          1. 12.2.10.1. Methods
          2. 12.2.10.2. Properties
        11. 12.2.11. LogonTrigger
          1. 12.2.11.1. Methods
          2. 12.2.11.2. Properties
        12. 12.2.12. MonthlyDOWTrigger
          1. 12.2.12.1. Methods
          2. 12.2.12.2. Properties
        13. 12.2.13. MonthlyTrigger
          1. 12.2.13.1. Methods
          2. 12.2.13.2. Properties
        14. 12.2.14. NetworkSettings
          1. 12.2.14.1. Methods
          2. 12.2.14.2. Properties
        15. 12.2.15. Principal
          1. 12.2.15.1. Methods
          2. 12.2.15.2. Properties
        16. 12.2.16. RegisteredTask
          1. 12.2.16.1. Methods
          2. 12.2.16.2. Properties
        17. 12.2.17. RegisteredTaskCollection
          1. 12.2.17.1. Methods
          2. 12.2.17.2. Properties
        18. 12.2.18. RegistrationInfo
          1. 12.2.18.1. Methods
          2. 12.2.18.2. Properties
        19. 12.2.19. RegistrationTrigger
          1. 12.2.19.1. Methods
          2. 12.2.19.2. Properties
        20. 12.2.20. RepetitionPattern
          1. 12.2.20.1. Methods
          2. 12.2.20.2. Properties
        21. 12.2.21. RunningTask
          1. 12.2.21.1. Methods
          2. 12.2.21.2. Properties
        22. 12.2.22. RunningTaskCollection
          1. 12.2.22.1. Methods
          2. 12.2.22.2. Properties
        23. 12.2.23. SessionStateChangeTrigger
          1. 12.2.23.1. Methods
          2. 12.2.23.2. Properties
        24. 12.2.24. ShowMessageAction
          1. 12.2.24.1. Methods
          2. 12.2.24.2. Properties
        25. 12.2.25. TaskDefinition
          1. 12.2.25.1. Methods
          2. 12.2.25.2. Properties
        26. 12.2.26. TaskFolder
          1. 12.2.26.1. Methods
          2. 12.2.26.2. Properties
        27. 12.2.27. TaskFolderCollection
          1. 12.2.27.1. Methods
          2. 12.2.27.2. Properties
        28. 12.2.28. TaskNamedValuePair
          1. 12.2.28.1. Methods
          2. 12.2.28.2. Properties
        29. 12.2.29. TaskNamedValueCollection
          1. 12.2.29.1. Methods
          2. 12.2.29.2. Properties
        30. 12.2.30. TaskService
          1. 12.2.30.1. Methods
          2. 12.2.30.2. Properties
        31. 12.2.31. TaskSettings
          1. 12.2.31.1. Methods
          2. 12.2.31.2. Properties
        32. 12.2.32. TaskVariables
          1. 12.2.32.1. Methods
          2. 12.2.32.2. Properties
        33. 12.2.33. TimeTrigger
          1. 12.2.33.1. Methods
          2. 12.2.33.2. Properties
        34. 12.2.34. Trigger
          1. 12.2.34.1. Methods
          2. 12.2.34.2. Properties
        35. 12.2.35. TriggerCollection
          1. 12.2.35.1. Methods
          2. 12.2.35.2. Properties
        36. 12.2.36. WeeklyTrigger
          1. 12.2.36.1. Methods
          2. 12.2.36.2. Properties
      3. 12.3. Sample Task Scheduler Script
      4. 12.4. Summary
    18. 13. PowerShell
      1. 13.1. Requirements
      2. 13.2. Features
      3. 13.3. Why a New Scripting Language?
      4. 13.4. Getting Started
        1. 13.4.1. Using PowerShell
        2. 13.4.2. Deeper into PowerShell
          1. 13.4.2.1. Using Aliases
          2. 13.4.2.2. Using Functions
          3. 13.4.2.3. Navigating the File System
          4. 13.4.2.4. Navigating the Windows Registry
      5. 13.5. Working with Scripts in PowerShell
        1. 13.5.1. Changing PowerShell Execution Policy
        2. 13.5.2. Naming Scripts
      6. 13.6. Creating and Calling Your First PowerShell Cmdlet Script
      7. 13.7. The Connection Between VBScript and PowerShell?
        1. 13.7.1. Operators
        2. 13.7.2. Functions
        3. 13.7.3. Statements
      8. 13.8. Summary
    19. 14. Super-Charged Client-Side Scripting
      1. 14.1. Requirements and Browser Security
      2. 14.2. Scriptlets — Ancestors of Behaviors
        1. 14.2.1. What Is a Scriptlet?
        2. 14.2.2. The Prefix public_ Exposes Scriptlet Members
        3. 14.2.3. Packaging Code in a Scriptlet for Reuse
          1. 14.2.3.1. Using the Cookies Manager
          2. 14.2.3.2. How Does It Work?
      3. 14.3. Event Management
        1. 14.3.1. Relationship to the Event Handler
          1. 14.3.1.1. Standard DHTML Events
          2. 14.3.1.2. Custom Events
          3. 14.3.1.3. How Do You Know When a Scriptlet Is Ready?
        2. 14.3.2. Scriptlet Model Extensions
          1. 14.3.2.1. Frozen Property
          2. 14.3.2.2. SelectableContent Property
          3. 14.3.2.3. Version Property
          4. 14.3.2.4. BubbleEvent Method
          5. 14.3.2.5. RaiseEvent Method
          6. 14.3.2.6. SetContextMenu Method
      4. 14.4. Scriptlets Are Deprecated in IE5
        1. 14.4.1. Behaviors
        2. 14.4.2. Which Technologies Implement Behaviors?
        3. 14.4.3. Applying a Behavior to an HTML Element
          1. 14.4.3.1. Applying a Behavior Statically
          2. 14.4.3.2. Applying a Behavior Dynamically
          3. 14.4.3.3. Removing a Behavior Attached Dynamically
      5. 14.5. HTML Components (HTCs)
        1. 14.5.1. Extending HTML Elements Behavior
          1. 14.5.1.1. Enhancement 1: Adding Properties
          2. 14.5.1.2. Enhancement 2: Adding Methods
          3. 14.5.1.3. Enhancement 3: Exposing Component Events
          4. 14.5.1.4. Enhancement 4: Handling HTML Element Events
          5. 14.5.1.5. Attach Event Handlers Through Scripting
          6. 14.5.1.6. Multiple Behaviors
          7. 14.5.1.7. Name Clashing Resolution and the Component Element
      6. 14.6. Summary
    20. 15. Windows Script Host
      1. 15.1. Tools of the Trade
      2. 15.2. What Is WSH?
      3. 15.3. Types of Script Files
      4. 15.4. Running Scripts with the Windows Script Host
        1. 15.4.1. Command-Line Execution
        2. 15.4.2. Execution of WSH within the Windows Environment
      5. 15.5. Using .WSH Files to Launch Scripts
      6. 15.6. Windows Script Host Intrinsic Objects
        1. 15.6.1. The WScript Object
          1. 15.6.1.1. WScript Properties
            1. 15.6.1.1.1. Arguments
            2. 15.6.1.1.2. FullName
            3. 15.6.1.1.3. Interactive
            4. 15.6.1.1.4. Name
            5. 15.6.1.1.5. Path
            6. 15.6.1.1.6. ScriptFullName
            7. 15.6.1.1.7. ScriptName
            8. 15.6.1.1.8. StdErr
            9. 15.6.1.1.9. StdIn
            10. 15.6.1.1.10. StdOut
            11. 15.6.1.1.11. Version
          2. 15.6.1.2. WScript Methods
            1. 15.6.1.2.1. CreateObject
            2. 15.6.1.2.2. ConnectObject
            3. 15.6.1.2.3. DisconnectObject
            4. 15.6.1.2.4. Echo
            5. 15.6.1.2.5. GetObject
            6. 15.6.1.2.6. Quit
            7. 15.6.1.2.7. Sleep
        2. 15.6.2. The WshArguments Object
          1. 15.6.2.1. Accessing the WshArguments Object
          2. 15.6.2.2. WshArguments Properties
        3. 15.6.3. The WshShell Object
          1. 15.6.3.1. Accessing the WshShell Object
          2. 15.6.3.2. WshShell Properties
            1. 15.6.3.2.1. CurrentDirectory
            2. 15.6.3.2.2. Environment
            3. 15.6.3.2.3. SpecialFolders
          3. 15.6.3.3. WshShell Methods
            1. 15.6.3.3.1. AppActivate
            2. 15.6.3.3.2. CreateShortcut
            3. 15.6.3.3.3. ExpandEnvironmentStrings
            4. 15.6.3.3.4. LogEvent
            5. 15.6.3.3.5. Popup
          4. 15.6.3.4. Button Types
          5. 15.6.3.5. Icon Types
            1. 15.6.3.5.1. RegDelete
            2. 15.6.3.5.2. RegRead
            3. 15.6.3.5.3. RegWrite
            4. 15.6.3.5.4. Run
            5. 15.6.3.5.5. SendKeys
            6. 15.6.3.5.6. Exec
        4. 15.6.4. The WshNamed Object
          1. 15.6.4.1. Accessing the WshNamed Object
          2. 15.6.4.2. WshNamed Properties
            1. 15.6.4.2.1. Item
            2. 15.6.4.2.2. Length
          3. 15.6.4.3. WshNamed Methods
            1. 15.6.4.3.1. Count
            2. 15.6.4.3.2. Exists
        5. 15.6.5. The WshUnnamed Object
          1. 15.6.5.1. Accessing the WshUnnamed Object
          2. 15.6.5.2. WshUnnamed Properties
          3. 15.6.5.3. WshUnnamed Methods
        6. 15.6.6. The WshNetwork Object
          1. 15.6.6.1. Accessing the WshNetwork Object
          2. 15.6.6.2. WshNetwork Properties
            1. 15.6.6.2.1. ComputerName
            2. 15.6.6.2.2. UserDomain
            3. 15.6.6.2.3. UserName
          3. 15.6.6.3. WshNetwork Methods
            1. 15.6.6.3.1. AddWindowsPrinterConnection
            2. 15.6.6.3.2. AddPrinterConnection
            3. 15.6.6.3.3. EnumNetworkDrives
            4. 15.6.6.3.4. EnumPrinterConnection
            5. 15.6.6.3.5. MapNetworkDrive
            6. 15.6.6.3.6. RemoveNetworkDrive
            7. 15.6.6.3.7. RemovePrinterConnection
            8. 15.6.6.3.8. SetDefaultPrinter
        7. 15.6.7. The WshEnvironment Object
          1. 15.6.7.1. Accessing the WshEnvironment Object
          2. 15.6.7.2. WshEnvironment Properties
            1. 15.6.7.2.1. Item
            2. 15.6.7.2.2. Length
          3. 15.6.7.3. WshEnvironment Methods
            1. 15.6.7.3.1. Count
            2. 15.6.7.3.2. Remove
        8. 15.6.8. The WshSpecialFolders Object
          1. 15.6.8.1. WshSpecialFolders Properties: Item
          2. 15.6.8.2. WshSpecialFolders Methods: Count
        9. 15.6.9. The WshShortcut Object
          1. 15.6.9.1. WshShortcut Properties
            1. 15.6.9.1.1. Arguments
            2. 15.6.9.1.2. Description
            3. 15.6.9.1.3. FullName
            4. 15.6.9.1.4. Hotkey
            5. 15.6.9.1.5. IconLocation
            6. 15.6.9.1.6. TargetPath
            7. 15.6.9.1.7. WindowStyle
            8. 15.6.9.1.8. WorkingDirectory
          2. 15.6.9.2. WshShortcut Methods
        10. 15.6.10. The WshUrlShortcut Object
          1. 15.6.10.1. WshUrlShortcut Properties
            1. 15.6.10.1.1. FullName
            2. 15.6.10.1.2. TargetPath
          2. 15.6.10.2. WshUrlShortcut Methods
      7. 15.7. Summary
    21. 16. Windows Script Components
      1. 16.1. What Are Windows Script Components?
      2. 16.2. What Tools Do You Need?
      3. 16.3. The Script Component Runtime
      4. 16.4. Script Component Files and Wizard
      5. 16.5. Exposing Properties, Methods, and Events
        1. 16.5.1. Properties
        2. 16.5.2. Methods
        3. 16.5.3. Events
      6. 16.6. Registration Information
      7. 16.7. Creating the Script Component Type Libraries
      8. 16.8. How to Reference Other Components
      9. 16.9. Script Components for ASP
      10. 16.10. Compile-Time Error Checking
      11. 16.11. Using VBScript Classes in Script Components
        1. 16.11.1. Limitations of VBScript Classes
        2. 16.11.2. Using Internal Classes
        3. 16.11.3. Including External Source Files
      12. 16.12. Summary
    22. 17. Script Encoding
      1. 17.1. Limitations of Script Encoding
      2. 17.2. Encoded Scripts — Dos and Don'ts
      3. 17.3. Encoding with the Microsoft Script Encoder
        1. 17.3.1. Availability and Installation
        2. 17.3.2. Using the Microsoft Script Encoder
        3. 17.3.3. Syntax
        4. 17.3.4. What Files Can I Encode?
          1. 17.3.4.1. HTML Files
          2. 17.3.4.2. ASP Files
          3. 17.3.4.3. Plain Text
          4. 17.3.4.4. Scriptlets
      4. 17.4. Decoding the Script
      5. 17.5. Other Methods of Script Obfuscation
      6. 17.6. Summary
    23. 18. Remote Scripting
      1. 18.1. How Remote Scripting Works
        1. 18.1.1. Security
        2. 18.1.2. Files You Need for Remote Scripting
      2. 18.2. Using VBScript for Remote Scripting
        1. 18.2.1. Installing Remote Script on the Server
        2. 18.2.2. Enabling Remote Scripting on the Server
        3. 18.2.3. Enabling Remote Scripting on the Client Side
        4. 18.2.4. Invoking a Remote Method
        5. 18.2.5. Transforming an ASP Page into a VBScript Object
      3. 18.3. Summary
    24. 19. HTML Applications
      1. 19.1. The Advantage of an HTML Application
      2. 19.2. How to Create a Basic HTA
        1. 19.2.1. Sample HTML File
        2. 19.2.2. Turning an HTML File into an HTML Application
      3. 19.3. The HTA:APPLICATION Element
        1. 19.3.1. Modifying the Look of Your Application
        2. 19.3.2. Changing Parameters from the Command Line
        3. 19.3.3. Accessing Other HTA:APPLICATION Attributes
      4. 19.4. HTAs and Security
        1. 19.4.1. Addressing Frames Security Issues
        2. 19.4.2. Using the APPLICATION Attribute
        3. 19.4.3. Using Nested Frames
      5. 19.5. HTA Deployment Models
        1. 19.5.1. Web Model
        2. 19.5.2. Package Model
        3. 19.5.3. Hybrid Model
      6. 19.6. What Isn't Supported with HTAs?
        1. 19.6.1. The Window Object
        2. 19.6.2. Default Behaviors
      7. 19.7. Summary
    25. 20. Server-Side Web Scripting
      1. 20.1. Understanding the Anatomy of the HTTP Protocol
        1. 20.1.1. The HTTP Server
        2. 20.1.2. Protocol Basics
          1. 20.1.2.1. The Connection
          2. 20.1.2.2. The Request
          3. 20.1.2.3. The Response
          4. 20.1.2.4. The Disconnect
      2. 20.2. Introducing Active Server Pages
        1. 20.2.1. How the Server Recognizes ASPs
        2. 20.2.2. ASP Basics
        3. 20.2.3. The Tags of ASP
          1. 20.2.3.1. Using <SCRIPT> Blocks
          2. 20.2.3.2. Specifying the Default Scripting Language
          3. 20.2.3.3. Mixing HTML and ASP
          4. 20.2.3.4. Commenting Your ASP Code
      3. 20.3. Using the Active Server Pages Object Model
        1. 20.3.1. Collections
          1. 20.3.1.1. Iterating the Contents Collection
          2. 20.3.1.2. Removing an Item from the Contents Collection
        2. 20.3.2. The Request Object's Collection
          1. 20.3.2.1. QueryString
          2. 20.3.2.2. Form
          3. 20.3.2.3. Cookies
          4. 20.3.2.4. ClientCertificate
          5. 20.3.2.5. ServerVariables
          6. 20.3.2.6. Request Object Properties and Methods
          7. 20.3.2.7. TotalBytes Property
          8. 20.3.2.8. BinaryRead Method
        3. 20.3.3. The Response Object's Collection
          1. 20.3.3.1. The Response Object's Methods
        4. 20.3.4. The Response Object's Properties
          1. 20.3.4.1. Buffer
          2. 20.3.4.2. CacheControl
          3. 20.3.4.3. Charset
          4. 20.3.4.4. ContentType
          5. 20.3.4.5. Expires
          6. 20.3.4.6. ExpiresAbsolute
          7. 20.3.4.7. IsClientConnected
          8. 20.3.4.8. Status
        5. 20.3.5. Understanding the Application and Session Objects
          1. 20.3.5.1. Scope
          2. 20.3.5.2. The global.asa File
        6. 20.3.6. The Application Object
          1. 20.3.6.1. Collections
          2. 20.3.6.2. Methods
          3. 20.3.6.3. Events
        7. 20.3.7. The Session Object
          1. 20.3.7.1. Collections
          2. 20.3.7.2. Properties
          3. 20.3.7.3. Methods
          4. 20.3.7.4. Events
        8. 20.3.8. The Server Object
          1. 20.3.8.1. ScriptTimeout
          2. 20.3.8.2. CreateObject
          3. 20.3.8.3. Execute
          4. 20.3.8.4. GetLastError
          5. 20.3.8.5. HTMLEncode
          6. 20.3.8.6. MapPath
          7. 20.3.8.7. Transfer
          8. 20.3.8.8. URLEncode
        9. 20.3.9. The ObjectContext Object
          1. 20.3.9.1. SetAbort
          2. 20.3.9.2. SetComplete
      4. 20.4. Using Active Server Pages Effectively
        1. 20.4.1. Designing the Site
        2. 20.4.2. Creating the global.asa File
        3. 20.4.3. Creating the Main Page
        4. 20.4.4. The ASP/VBScript Section
        5. 20.4.5. The HTML Section
      5. 20.5. Summary
    26. 21. Adding VBScript to Your VB and .NET Applications
      1. 21.1. Why Add Scripting to Your Application?
      2. 21.2. Macro and Scripting Concepts
        1. 21.2.1. Using Scriptlets
        2. 21.2.2. Using Scripts
        3. 21.2.3. Which Scope Is the Best?
      3. 21.3. Adding the Script Control to a VB 6 or .NET Application
      4. 21.4. Script Control Reference
        1. 21.4.1. Object Model
        2. 21.4.2. Objects and Collections
          1. 21.4.2.1. ScriptControl Object
            1. 21.4.2.1.1. Declaration Syntax
            2. 21.4.2.1.2. Properties
            3. 21.4.2.1.3. Methods
            4. 21.4.2.1.4. Events
            5. 21.4.2.1.5. Examples
          2. 21.4.2.2. Module Object
            1. 21.4.2.2.1. Declaration Syntax
            2. 21.4.2.2.2. Properties
            3. 21.4.2.2.3. Methods
            4. 21.4.2.2.4. Examples
          3. 21.4.2.3. Modules Collection
            1. 21.4.2.3.1. Properties
            2. 21.4.2.3.2. Methods
            3. 21.4.2.3.3. Examples
          4. 21.4.2.4. Procedure Object
            1. 21.4.2.4.1. Declaration Syntax
            2. 21.4.2.4.2. Properties
            3. 21.4.2.4.3. Methods
          5. 21.4.2.5. Procedures Collection
            1. 21.4.2.5.1. Properties
            2. 21.4.2.5.2. Methods
            3. 21.4.2.5.3. Examples
          6. 21.4.2.6. Error Object
            1. 21.4.2.6.1. Properties
            2. 21.4.2.6.2. Methods
        3. 21.4.3. Constants
          1. 21.4.3.1. GlobalModule Named Constant
          2. 21.4.3.2. NoTimeout Named Constant
          3. 21.4.3.3. ScriptControlState Enumerated Constant
      5. 21.5. Error Handling with the Script Control
      6. 21.6. Debugging
      7. 21.7. Using Encoded Scripts
      8. 21.8. Sample .NET Project
      9. 21.9. Sample Visual Basic 6 Project
      10. 21.10. Summary
    27. A. VBScript Functions and Keywords
      1. A.1. Operators
        1. A.1.1. Assignment Operator
        2. A.1.2. Arithmetic Operators
        3. A.1.3. Concatenation Operators
        4. A.1.4. Comparison Operators
        5. A.1.5. Logical Operators
        6. A.1.6. Bitwise Operators
        7. A.1.7. Operator Precedence
        8. A.1.8. Unsupported Operators
        9. A.1.9. Math Functions
      2. A.2. Date and Time Functions and Statements
      3. A.3. Unsupported Date Functions and Statements
      4. A.4. Array Functions and Statements
      5. A.5. String Functions and Statements
      6. A.6. Unsupported String Functions, Statements, and Constructs
      7. A.7. String Constants
      8. A.8. Conversion Functions
      9. A.9. Unsupported Conversion Functions
      10. A.10. Miscellaneous Functions, Statements, and Keywords
    28. B. Variable Naming Convention
    29. C. Coding Conventions
      1. C.1. Constants
      2. C.2. Arrays
      3. C.3. Procedure Naming
      4. C.4. Indentation
      5. C.5. Commenting
    30. D. Visual Basic Constants Supported in VBScript
      1. D.1. Color Constants
      2. D.2. Comparison Constants
      3. D.3. Date Format Constants
      4. D.4. Miscellaneous Constants
      5. D.5. MsgBox Constants
      6. D.6. String Constants
      7. D.7. Tristate Constants
      8. D.8. VarType Constants
    31. E. VBScript Error Codes and the Err Object
      1. E.1. Runtime Errors
      2. E.2. Syntax Errors
      3. E.3. Understanding the Err Object
        1. E.3.1. Err Object Properties
          1. E.3.1.1. Syntax
          2. E.3.1.2. Example Usage
        2. E.3.2. HelpContext
          1. E.3.2.1. Syntax
          2. E.3.2.2. Example Usage
        3. E.3.3. HelpFile
          1. E.3.3.1. Syntax
        4. E.3.4. Number
          1. E.3.4.1. Syntax
          2. E.3.4.2. Example Usage
        5. E.3.5. Source
          1. E.3.5.1. Syntax
          2. E.3.5.2. Example Usage
      4. E.4. Err Object Methods
        1. E.4.1. Clear
          1. E.4.1.1. Syntax
          2. E.4.1.2. Example Usage
        2. E.4.2. Raise
          1. E.4.2.1. Syntax
          2. E.4.2.2. Example Usage
        3. E.4.3. vbObjectError Constant
          1. E.4.3.1. Example Usage
        4. E.4.4. On Error Resume Next
          1. E.4.4.1. Syntax
        5. E.4.5. On Error Goto 0
          1. E.4.5.1. Syntax
      5. E.5. Scope of On Error Statement and How VBScript's and VBs (or VBAs) Error Handling Differ
      6. E.6. Error Handling in Internet Explorer
        1. E.6.1. Old Syntax
        2. E.6.2. New Syntax
    32. F. The Scripting Runtime Library Object Reference
      1. F.1. The Scripting.Dictionary Object
        1. F.1.1. Properties
        2. F.1.2. Methods
      2. F.2. The Scripting.FileSystemObject Object
        1. F.2.1. The FileSystemObject Object
          1. F.2.1.1. Property
          2. F.2.1.2. Method
        2. F.2.2. The Drive Object
        3. F.2.3. The Folder Object
          1. F.2.3.1. Properties
          2. F.2.3.2. Methods
        4. F.2.4. The File Object
          1. F.2.4.1. Properties
          2. F.2.4.2. Methods
      3. F.3. The TextStream Object
        1. F.3.1. Properties
        2. F.3.2. Methods
    33. G. The Windows Script Host Object Model
      1. G.1. The Scripting.Signer Object
      2. G.2. The WScript Object
      3. G.3. The WshArguments Object
      4. G.4. WshController Object
      5. G.5. WshEnvironment Object
      6. G.6. WshNamed Object
      7. G.7. The WshNetwork Object
      8. G.8. WshRemote Object
      9. G.9. WshRemoteError Object
      10. G.10. WshScriptExec Object
      11. G.11. The WshShell Object
      12. G.12. The WshShortcut Object
      13. G.13. The WshSpecialFolders Object
      14. G.14. The WshUnnamed Object
      15. G.15. The WshUrlShortcut Object
    34. H. Regular Expressions
    35. I. The Variant Subtypes
      1. I.1. The Variant Subtypes
      2. I.2. The Visual Basic Data Types
    36. J. ActiveX Data Objects
      1. J.1. The Connection Object
        1. J.1.1. Connection Object Properties
        2. J.1.2. Connection Object Methods
      2. J.2. The Command Object
      3. J.3. Command Object Properties
        1. J.3.1. Command Object Methods
      4. J.4. The Parameters and Parameter Objects
        1. J.4.1. Parameter Object Properties
        2. J.4.2. Parameter Object Methods
        3. J.4.3. Parameters Object Properties
        4. J.4.4. Parameters Object Methods
      5. J.5. The Recordset Object
        1. J.5.1. Recordset Object Properties
        2. J.5.2. Recordset Object Methods
      6. J.6. ADO Enumerated Constants

    Product information

    • Title: VBScript Programmer's Reference, Third Edition
    • Author(s): Kathie Kingsley-Hughes, Daniel Read, Adrian Kingsley-Hughes
    • Release date: October 2007
    • Publisher(s): Wrox
    • ISBN: 9780470168080