Microsoft® Windows® 2000 Scripting Guide

Book description

Focusing on scripting for the administrator, this guide helps you understand important scripting concepts and technologies, and it shows how to use common scripting tools and techniques to complete routine tasks in core administrative areas.

Table of contents

  1. Copyright
  2. Introduction
    1. Compact Disc
    2. Document Conventions
      1. Scripting Diagram Symbols
      2. Reader Alert Conventions
      3. Command-line Style Conventions
    3. Support Policy
  3. I. Scripting Concepts and Technologies for System Administration
    1. 1. Introduction to Windows Script Technologies
      1. How Did Scripting Acquire Such a Bad Reputation?
      2. How This Book Helps
      3. How Do You Know if This Book is for You?
      4. What Is in This Book
      5. About the Scripts Used in This Book
        1. A Note Regarding VBScript
      6. System Requirements
    2. 2. VBScript Primer
      1. VBScript Overview
        1. Working with Objects
          1. Connecting to Objects
            1. Connecting to WSH
          2. Creating an Object Reference
          3. Calling Methods
          4. Retrieving Properties
        2. Variables
        3. Constants
        4. Strings
          1. Strings as Variables
          2. Concatenating Strings
        5. Collections
          1. For Each
          2. Collections with Zero Items
        6. Looping
          1. For Next
        7. Making Decisions
          1. Taking Multiple Actions by Using If Then Else
        8. Arrays
        9. Input
        10. Error Handling
          1. Using the Err Object
          2. Clearing Errors
      2. VBScript Reference
        1. Working with Variables
          1. Initializing Variables
        2. Using Constants
          1. Defining Constants
          2. Using Intrinsic Constants
        3. VBScript Data Types
        4. Working with Dates and Times
          1. Retrieving Current Date and Time Values
          2. Verifying That a Value Is a Date
          3. Retrieving Specific Portions of a Date and Time Value
          4. Date Arithmetic
          5. Formatting Date and Time Values
        5. Working with Strings
          1. Manipulating Strings and String Lengths
            1. Creating Tabular Output
          2. Searching for Text in a String
          3. Modifying String Case
        6. Working with Numbers
          1. Arithmetic Precedence
          2. Formatting Numbers
          3. Formatting Percentages
        7. Running Statements Multiple Times
          1. Do Loop
            1. Creating Endless Loops
          2. Checking the Loop Condition
          3. Exiting a Loop
        8. Making Decisions
          1. Testing Multiple Conditions
          2. If Then ElseIf
          3. Select Case
        9. Arrays
          1. Creating Arrays
            1. Declaring and Populating Arrays
          2. Creating Dynamic Arrays
          3. Converting a Delimited String to an Array
          4. Alternatives to Using Arrays
        10. Error Handling
          1. Handling Run-Time Errors
            1. Ignoring All Errors
            2. Responding to Errors
          2. Toggling Error Handling
          3. Handling Errors in COM Objects
        11. Procedures
          1. Calling a Procedure
          2. Functions
            1. Passing Parameters to Functions
            2. Passing Parameters by Value or by Reference
          3. Recursion
        12. COM Objects
          1. The COM Process
            1. Creating a New Object
            2. Server Mode
          2. Binding
          3. Choosing a Method for Binding to an Automation Object
          4. Verifying Object References
          5. Unloading Objects from Memory
            1. Nothing Keyword
    3. 3. WSH Primer
      1. WSH Overview
      2. WSH Architecture
        1. Components of the WSH Environment
        2. How the Components of the WSH Environment Work Together
        3. WSH Object Model
      3. Running WSH Scripts
        1. Running Scripts from the Command Line
        2. Scheduling the Running of Scripts
        3. Other Methods of Running Scripts
      4. WSH Objects
        1. WScript Object
          1. Using COM Objects
            1. Creating a New Instance of a COM Object
            2. Attaching to an Existing Instance of a COM Object
            3. Comparing VBScript CreateObject and GetObject Functions with WSH
          2. Handling Input and Output
            1. Displaying Messages to Script Users
            2. Getting Text into and out of Scripts
            3. Displaying Output Using StdOut
            4. Reading Input by Using StdIn
          3. Working with Command-Line Arguments
            1. How Command-Line Arguments Are Stored and Filtered
            2. Using the Default Arguments Collection
            3. Unnamed Command-Line Arguments
            4. Named Command-Line Arguments
            5. Using Both Unnamed and Named Arguments
            6. Verifying Command-Line Arguments
          4. Controlling How a Script Runs
            1. Pausing a Script
            2. Quitting a Script
            3. Setting a Time-out Value for a Script
          5. Obtaining WSH Environment Information
          6. Handling Events
        2. WshShell Object
          1. Running Programs
            1. Comparing Run and Exec
            2. Running Programs
            3. Running Command-Line Tools
            4. Using Spaces in Command-Line Parameters
            5. Running a Program and Directly Accessing Its Output
          2. Working with Shortcuts
            1. Creating Standard Shortcuts
            2. Creating URL Shortcuts
            3. Adding an Item to the Quick Launch Bar
            4. Deleting Shortcuts
          3. Working with Special Folders
            1. Retrieving the Location of Special Folders
            2. Creating a Shortcut in a Special Folder
          4. Environment Variables
            1. Retrieving Environment Variables
            2. Creating Environment Variables
            3. Modifying Environment Variables
            4. Expanding Environment Variables
          5. Logging an Event
          6. Reading From and Writing to the Local Registry
            1. Reading a Registry Entry
            2. Creating or Modifying a Registry Entry
            3. Deleting a Registry Entry
          7. Sending Keystrokes to a Program
          8. Retrieving and Changing a Script’s Current Working Directory
          9. Displaying Timed Message Boxes
            1. Comparing the Echo and Popup Methods
            2. Creating a Message Box That Times Out
            3. Choosing Icons and Buttons
            4. Choosing the Default Button
            5. Retrieving User Input
        3. WshNetwork Object
          1. Managing Network Drives
            1. Mapping a Network Drive
            2. Unmapping a Network Drive
            3. Listing Current Network Drives
          2. Managing Network Printers
            1. Adding Printer Connections
            2. Removing a Printer Connection
            3. Enumerating the Available Printers
            4. Setting the Default Printer
          3. Obtaining User and Computer Information
        4. WshController Object
          1. Running Scripts on Remote Computers
          2. Monitoring Status of Remotely Running Scripts
          3. Examining Errors Produced by Remotely Running Scripts
          4. Limitations of Remote WSH
      5. Securing Scripts
        1. Digitally Signing Scripts
          1. Enforcing the Use of Signed Scripts
          2. Programmatically Signing a Script
          3. Programmatically Verifying a Signed Script
        2. Restricting the Ability to Run Scripts
          1. Disabling Windows Script Host
    4. 4. Script Runtime Primer
      1. Script Runtime Overview
      2. FileSystemObject
        1. Managing Disk Drives
          1. Returning a Collection of Disk Drives
          2. Binding to a Specific Disk Drive
          3. Enumerating Disk Drive Properties
          4. Ensuring that a Drive is Ready
        2. Managing Folders
          1. Binding to a Folder
          2. Verifying That a Folder Exists
          3. Creating a Folder
          4. Deleting a Folder
            1. Using Wildcards to Delete Folders
          5. Copying a Folder and Its Contents
            1. Using Wildcards to Copy Folders
          6. Moving a Folder and Its Contents
          7. Renaming a Folder
        3. Using Folder Properties
          1. Enumerating Folder Properties
        4. Managing Folder Attributes
          1. Changing Folder Attributes
          2. Enumerating the Files in a Folder
          3. Enumerating Subfolders
            1. Enumerating Subfolders Within Subfolders
        5. Managing Files
          1. Binding to a File
          2. Verifying That a File Exists
          3. Deleting a File
            1. Deleting a Set of Files
          4. Copying a File
            1. Copying a Set of Files
          5. Moving a File
            1. Moving a Set of Files
          6. Renaming a File
        6. Retrieving File Properties
          1. Enumerating File Attributes
          2. Configuring File Attributes
          3. Parsing File Paths
          4. Retrieving the File Version
        7. Reading and Writing Text Files
          1. Reading Text Files
            1. Verifying the Size of a File
            2. Reading an Entire Text File
            3. Reading a Text File Line by Line
            4. “Reading” a Text File from the Bottom to the Top
            5. Reading a Text File Character by Character
          2. Writing to Text Files
            1. Overwriting Existing Data
            2. Appending New Data to Existing Data
      3. Dictionary Object
        1. Creating a Dictionary
          1. Configuring Dictionary Properties
          2. Adding Key-Item Pairs to a Dictionary
            1. Inadvertently Adding a Key to a Dictionary
        2. Manipulating Keys and Items in a Dictionary
          1. Determining the Number of Key-Item Pairs in a Dictionary
          2. Enumerating Keys and Items in a Dictionary
          3. Verifying the Existence of a Specific Key
          4. Modifying an Item in a Dictionary
          5. Removing Key-Item Pairs from a Dictionary
            1. Removing All Key-Item Pairs from a Dictionary
            2. Removing a Specific Key-Item Pair from a Dictionary
    5. 5. ADSI Scripting Primer
      1. ADSI Overview
      2. ADSI Scripting Fundamentals
        1. Primary ADSI Scripting Tasks
          1. Creating Directory Service Objects
            1. Creating an OU
            2. Creating a User Account
            3. Creating a Group
          2. Modifying Directory Service Objects
            1. Modifying an Attribute of an OU
            2. Modifying an Attribute of a User Account
            3. Modifying an Attribute of a Group
          3. Reading Attributes of Directory Service Objects
            1. Reading an Attribute of an OU
            2. Reading an Attribute of a User Account
            3. Reading an Attribute of a Group
          4. Deleting Directory Service Objects
            1. Deleting a Group
            2. Deleting a User Account
            3. Deleting an OU
        2. Comparing the Primary Scripting Tasks
        3. Building ADSI Scripts
          1. Step 1: Establishing a Connection
            1. Choosing a Directory Service Object for a Binding Operation
            2. Performing a Binding Operation
            3. ADsPath
            4. Creating an Object Reference to the Directory Object
          2. Step 2: Performing a Task
            1. Task Code
            2. Method Parameters
          3. Step 3: Committing to Active Directory
        4. Performing Multiple Scripting Tasks
          1. Preliminary Steps
            1. Binding to a User Account Object
            2. Writing or Modifying Attributes
            3. Reading and Displaying the Modified Attributes
      3. Advanced ADSI Scripting Operations
        1. Administering Multivalued Attributes
          1. Modifying Multivalued Attributes
            1. Restrictions in performing modifications by using the PutEx method
            2. Clearing multivalued and single-valued attributes with the PutEx method
            3. Updating a Multivalued Attribute of a Group
            4. Appending an Entry to a Multivalued Attribute of a Group
            5. Deleting an Entry from a Multivalued Attribute of a Group
            6. Clearing a Multivalued Attribute of a Group
            7. Updating Multivalued Attributes of a User Account
          2. Reading Multivalued Attributes
            1. Reading a Multivalued Attribute of a Group
            2. Reading Multivalued Attributes of a User Account
        2. Data Caching
          1. How the Get Method Retrieves Attributes
            1. How the GetEx Method Retrieves Attributes
          2. Making Explicit Calls by Using the GetInfo Method
          3. Making Explicit Calls by Using the GetInfoEx Method
        3. Copying, Moving, and Renaming Objects
          1. Copying Objects
            1. Copying a Computer Account
            2. Copying a User Account
          2. Moving and Renaming Objects
            1. General Conditions for Cross-Domain Moves
            2. Renaming a Published Printer
            3. Moving a Group from One Container to Another
            4. Moving an OU from One Domain to Another
        4. Searching
          1. Searching Active Directory
            1. Creating a Simple Search Script
            2. Scripting the Attributes to Be Returned by the Search
            3. Limiting a Search to a Specific Type of Object
            4. Specifying the Global Catalog in the Search Base
            5. Using Referral Chasing to Expand the Result Set
            6. Controlling the Scope of a Search
            7. Sorting the Results of a Search
            8. Retrieving Multivalued Attributes from a Search
            9. Using Range Limits When Retrieving Multivalued Attributes
          2. Optimizing Search Performance
            1. Consolidating Query Strings
            2. Limiting the Result Set
            3. Specifying Additional Command Object Properties
            4. Using the Global Catalog to Perform Search Operations
            5. Minimize Object Creation (Instantiation)
          3. Performing an Administrative Task Using a Result Set
            1. Modifying an Attribute in Multiple Objects
            2. Moving Objects Containing a Certain Value for an Attribute
        5. Enumerating Active Directory Objects in Containers
          1. Scripting Container Enumeration
            1. Enumerating the Contents of a Container
            2. Enumerating a Container to Perform an Administrative Task
            3. Limiting Container Enumeration to a Specific Object Type
        6. Root Directory Service Entry
          1. Scripting with rootDSE
            1. Binding to the Current Domain
            2. Binding to the Root Domain
            3. Binding to the Configuration Container
            4. Binding to the Schema Container
      4. Active Directory Architecture
        1. Physical Architecture
        2. Logical Structure
          1. Classes and Attributes
            1. Mandatory and Optional Attributes
            2. Class Inheritance and Categorization
            3. Snap-ins For Viewing and Configuring User Account Attributes, Classes, and Objects
          2. Active Directory Replication and Indexing
            1. Partitions Replicated on Domain Controllers
            2. Attributes Replicated to the Global Catalog
            3. Indexed Attributes
            4. Attributes That Are Both Replicated to the Global Catalog and Indexed
          3. Operational Attributes
      5. ADSI Architecture
        1. ADSI Layers
          1. Directory Namespace
            1. Providers
            2. Router
            3. Property Cache
            4. ADSI-Enabled Applications
        2. ADSI Interfaces
          1. Categorizing Interfaces
            1. LDAP Provider Objects and Their Interfaces
            2. IADs Properties
            3. IADsContainer Property
    6. 6. WMI Scripting Primer
      1. WMI Overview
      2. WMI Architecture
        1. Managed Resources
        2. WMI Infrastructure
        3. WMI Consumers
        4. WMI Security
          1. WMI Namespace-Level Security
          2. DCOM Security
          3. Standard Windows Operating System Security
      3. Common Information Model
        1. Blueprint for Management
          1. Namespaces
            1. Specifying a Namespace
            2. Managing the Default Namespace for Scripting
            3. Listing Namespaces
          2. Class Categories
            1. System Classes
            2. Core and Common Classes
            3. Extension Classes
            4. Listing Classes in a Namespace
          3. CIM Class Types
            1. Abstract Classes
            2. Static Classes
            3. Dynamic Classes
            4. Association Classes
          4. Components of a Class
            1. Properties
            2. Methods
            3. Qualifiers
            4. Comparing Classes with Managed Resources
            5. Retrieving Class Definitions
        2. Exploring the CIM Repository
      4. WMI Scripting Library
        1. WMI Scripting Library Object Model
          1. SWbemLocator
          2. SWbemServices
            1. SWbemObjectSet
      5. Writing WMI Scripts
        1. Connecting to WMI Using the WMI Moniker
          1. The “WinMgmts:” Prefix
          2. WMI Security Settings
            1. Impersonation Level
            2. Authentication Level
            3. Authority Setting
            4. Privileges
          3. Including Security Settings in Moniker Strings
          4. Using WMI Object Paths
            1. Formatting Object Paths
        2. Retrieving Managed Resources Using WMI Query Language
          1. Returning All Properties of All Instances of a Class
          2. Returning Selected Properties of All Instances of a Class
          3. Returning All Properties of Selected Instances of a Class
            1. Using Strings in WHERE Clauses
            2. Using Numbers and Boolean Values in WHERE Clauses
            3. Using Variables in WHERE Clauses
          4. Creating Targeted Queries Using AND or OR
          5. Returning Selected Properties of Selected Instances of a Class
          6. Creating Faster Queries by Using a Forward-only Enumerator
        3. Working with Dates and Times
          1. Converting WMI Dates to a Standard Date-Time Format
          2. Converting a Standard Date to a WMI Date-Time Format
            1. Determining the Offset from Greenwich Mean Time
            2. Converting a Date to a UTC Value
        4. Creating Scripts Based on WMI Templates
          1. Retrieving and Displaying Properties of a Managed Resource
          2. Retrieving and Displaying All Properties of a Managed Resource
          3. Writing Resource Properties
          4. Calling Methods
          5. Creating Resources
          6. Deleting Resources
        5. Monitoring Resources by Using WMI Event Notifications
          1. Three Steps in a WMI Monitoring Script
          2. How WMI Event Notification Works
            1. Intrinsic Events
            2. Extrinsic Events
          3. Enhanced WMI Monitoring Scripts
            1. Targeting a Particular Resource
            2. Handling More than One Event
            3. Handling More than One Type of Event
            4. Monitoring More than One Type of Managed Resource
            5. Monitoring Events by Using a Permanent Event Subscription
            6. The __EventFilter Class
            7. The Prebuilt __EventConsumer Classes
            8. The __FilterToConsumerBinding Class
  4. II. Scripting Solutions for System Administration
    1. 7. Active Directory Users
      1. User Account Overview
      2. Active Directory User Accounts
        1. Active Directory User Account Objects
          1. User Account Types
            1. User Account
            2. Contact Account
          2. Identification Attributes
            1. Security Principal Naming Attributes
      3. Creating User Accounts
        1. Configuring User Account Passwords
          1. Setting User Account Passwords
          2. Changing User Account Passwords
        2. Reading User Account Password Attributes
          1. Displaying Password Attributes Accessible from userAccountControl
          2. Determining When a Password Was Last Set
        3. Configuring User Account Password Attributes
          1. Changing Flags in the userAccountControl Attribute
          2. Configuring a Password Change at Next Logon Requirement
      4. Managing User Accounts
        1. Enabling or Disabling a User Account
        2. Determining Whether an Account Is Enabled or Disabled
        3. Reading and Writing User Account Attributes
          1. Reading Attributes
          2. Writing Values to the Attributes
          3. Modifying a Multivalued Attribute
          4. Clearing Attributes
        4. Copying, Moving, and Renaming User Accounts
          1. Copying User Accounts
          2. Moving and Renaming User Accounts
            1. Preparing a User Account for a Cross-Domain Move
      5. Deleting User Accounts
      6. Searching Active Directory for User Accounts
        1. Searching for an Attribute in a Container
        2. Limiting a Search for an Attribute in a Container to User Account Types
        3. Searching for a User Account Attribute in a Container and Its Subcontainers
        4. Verifying That an Attribute Is Unique in the Forest
        5. Searching for Empty Attribute Values
        6. Using Wildcards in Search Filters
        7. Searching for Multivalued Attributes
        8. Sorting the Result Set
        9. Modifying Multiple User Accounts by Using the Result Set from a Search
      7. Managing User Accounts by Enumeration
        1. Limiting Enumeration with Filters and Hints
    2. 8. Computer Assets
      1. Computer Assets Overview
        1. Retrieving System Information
        2. Retrieving BIOS Information
          1. Retrieving Information About the BIOS
          2. Retrieving Identifying Information by Using the SMBIOS
        3. Inventorying Computer Hardware
          1. Taking Inventory of Computer Hardware
          2. Identifying the Chassis Type of a Computer
      2. Managing Operating Systems
        1. Identifying the Name and Version Number of the Operating System
        2. Retrieving the Properties of the Operating System
        3. Identifying the Latest Installed Service Pack
        4. Enumerating Installed Hot Fixes
      3. Managing WMI Settings
        1. Enumerating WMI Settings
        2. Configuring WMI Settings
      4. Managing Software
        1. Enumerating Software
          1. Enumerating Installed Software
          2. Enumerating Installed Software Features
        2. Installing, Upgrading, and Removing Software
          1. Installing Software on the Local Computer
          2. Installing Software on a Remote Computer
            1. Trusting Users and Computers for Delegation
          3. Upgrading Software
          4. Removing Software
      5. Managing Computer States
        1. Managing Computer Startups
          1. Enumerating Computer Startup Options
          2. Configuring Computer Startup Options
          3. Enumerating Computer Startup Commands
        2. Managing Computer Recovery Options
          1. Enumerating Computer Recovery Options
          2. Configuring Computer Recovery Options
          3. Querying the Event Log for Stop Events
            1. Generating a Stop Event
        3. Shutting Down Computers and Logging Off Users
          1. Shutting Down a Computer
          2. Restarting a Computer
        4. Monitoring Changes in Computer Power Status
    3. 9. Computer Roles
      1. Computer Roles Overview
      2. Managing Computer Accounts
        1. Retrieving Basic Logon and Computer Information
        2. Creating Computer Accounts
          1. Setting Flags in the userAccountControl Attribute
        3. Deleting Computer Accounts
        4. Deleting Specified Computer Accounts
        5. Modifying Computer Accounts
          1. Enumerating Computer Account Attributes
          2. Configuring the Computer Account Location Attribute
          3. Renaming Computer Accounts
          4. Moving Computer Accounts
          5. Resetting Computer Account Passwords
        6. Searching for Computer Accounts in Active Directory
          1. Enumerating All the Computer Accounts in Active Directory
          2. Locating Computer Accounts Based on Their Attributes
      3. Managing Computer Roles
        1. Identifying Computer Roles
        2. Identifying the Role of a Computer Based on the Service It Provides
        3. Identifying Active Directory–Specific Roles
          1. Enumerating Domain Controllers
          2. Identifying the Current Domain Controller for a Computer
          3. Identifying Operations Master Roles
          4. Identifying Global Catalog Servers
          5. Enabling or Disabling Global Catalog Servers
    4. 10. Disks and File Systems
      1. Disks and File Systems Overview
      2. Managing and Monitoring Disk Drives
        1. Managing Disk Partitions
        2. Managing Logical Disk Drives
          1. Identifying Drives and Drive Types
          2. Changing Logical Disk Volume Names
        3. Managing Disk Space
          1. Enumerating Disk Space on a Computer
          2. Enumerating Disk Space by User
          3. Monitoring Free Disk Space in Real-Time
      3. Managing Disk Quotas
        1. Managing Disk Quotas on the NTFS File System
          1. Enumerating Disk Quota Settings
          2. Enabling and Disabling Disk Quotas
          3. Configuring Default Disk Quota Settings
        2. Managing Disk Quotas for Individual Users
          1. Enumerating Disk Quotas
            1. Issuing Disk Quota Alerts
          2. Adding a New Disk Quota Entry
          3. Modifying a Disk Quota Entry
          4. Deleting a Disk Quota Entry
      4. Managing File Systems
        1. Identifying the File System Type
        2. Enumerating NTFS Properties
        3. Modifying NTFS Properties
        4. Managing Page Files
          1. Monitoring Page File Use
          2. Configuring Page File Properties
    5. 11. Files and Folders
      1. Files and Folders Overview
        1. Managing Files and Folders Using WMI
          1. Comparing WMI and the FileSystemObject
            1. Speed
            2. Error Handling
            3. Remote Computers
            4. Ease of Use
        2. Managing Files and Folders Using the Windows Shell Object
      2. Folders and Folder Objects
        1. Enumerating Folders and Folder Properties
          1. Enumerating All the Folders on a Computer
          2. Enumerating the Subfolders of a Folder
          3. Enumerating a Specific Set of Folders
          4. Enumerating Folders by Date
          5. Enumerating Special Folders
          6. Enumerating the Items in a Special Folder
          7. Binding to a Folder by Using the Browse For Folder Dialog Box
        2. Managing Folders
          1. Renaming Folders
          2. Moving Folders by Using the Rename Method
          3. Copying Folders by Using WMI
          4. Copying Folders by Using the Shell Folder Object
          5. Moving Folders by Using the Shell Folder Object
          6. Deleting Folders
          7. Compressing and Uncompressing Folders
      3. Files and File Objects
        1. Enumerating Files and File Properties
          1. Retrieving Extended File Properties
          2. Enumerating All the Files on a Computer
          3. Using an Asynchronous Query to Enumerate All the Files on a Computer
          4. Enumerating All the Files in a Folder
          5. Enumerating a Specific Set of Files
        2. Managing Files
          1. Renaming Files
          2. Changing File Name Extensions
          3. Copying Files
          4. Deleting Files
          5. Performing Actions on Files
          6. Identifying Shell Object Verbs
      4. Monitoring the File System
        1. Monitoring File Creation
        2. Monitoring File Deletion
        3. Monitoring File Modification
      5. Managing Shared Folders
        1. Enumerating Shared Folders
        2. Creating Shared Folders
        3. Mapping Shared Folders to Local Folders
        4. Deleting Shared Folders
        5. Modifying Shared Folder Properties
        6. Publishing Shared Folders in Active Directory
        7. Managing Published Folders
          1. Enumerating Published Folders
          2. Searching for Published Folders in Active Directory
          3. Deleting a Published Folder in Active Directory
    6. 12. Logs
      1. Logs Overview
      2. Managing Logs
        1. Managing Event Logs
          1. Retrieving Event Log Properties
          2. Configuring Event Log Properties
          3. Backing Up and Clearing Event Logs
          4. Creating Unique File Names When Backing Up Event Logs
        2. Querying Event Logs
          1. Querying a Specific Event Log
          2. Querying an Event Log for a Subset of Events
          3. Retrieving Event Log Records from a Specified Day
          4. Asynchronously Retrieving Event Log Statistics
          5. Copying Events to a Database
        3. Writing Events to Event Logs
          1. Writing to Event Logs
          2. Creating Detailed Event Log Entry Descriptions
          3. Creating Custom Event Logs
        4. Managing Plain-Text Logs
          1. Parsing Comma-Separated-Values Logs
          2. Parsing Fixed-Width Logs
    7. 13. Printing
      1. Printing Overview
      2. Monitoring Printers, Print Queues, and Print Jobs
        1. Monitoring Printers
          1. Monitoring Printer Status
          2. Monitoring Printer Status in Real Time
          3. Filtering Printer Status Displays
          4. Monitoring Printer Status by Using a Temporary Event Subscription
          5. Verifying the Status of the Print Service
        2. Monitoring Printer Workloads
          1. Reporting Print Queue Statistics
        3. Monitoring Print Jobs
          1. Monitoring Print Job Status
          2. Monitoring the Time Print Jobs Spend in a Print Queue
      3. Managing Printer Operations, Print Queues, and Print Jobs
        1. Managing Printer Operations
          1. Enumerating Printers and Print Capabilities
          2. Pausing Printers
          3. Resuming Printers
        2. Managing Print Queues
          1. Purging Print Queues
        3. Managing Print Jobs
          1. Pausing Print Jobs
          2. Resuming Print Jobs
      4. Configuring Printers and Print Jobs
        1. Configuring Printer Properties
        2. Configuring Printer Availability
        3. Tracking Printer Locations
          1. Enabling Printer Location Tracking
          2. Configuring Printer Locations
        4. Configuring Print Jobs
          1. Configuring Print Job Properties
      5. Managing Printer Connections on Client Computers
        1. Enumerating Printer Connections
        2. Adding and Deleting Printer Connections
          1. Adding a Printer Connection by Using WSH
          2. Removing a Printer Connection
      6. Searching for Printers in Active Directory
        1. Enumerating All the Published Printers in a Domain
        2. Searching for Specific Printers in a Domain
    8. 14. Processes
      1. Processes Overview
      2. Managing Processes
        1. Monitoring Processes
          1. Monitoring Processes for Availability
          2. Monitoring Processes for Reliability
          3. Monitoring Processes for Performance
          4. Displaying Current Process Performance Data
        2. Enumerating Additional Process Properties
          1. Determining Process Owners
          2. Monitoring Threads
        3. Creating and Terminating Processes
          1. Creating Processes
          2. Modifying Process Startup Options
          3. Terminating Processes
    9. 15. Services
      1. Services Overview
      2. Monitoring Services
        1. Monitoring Service Availability
        2. Monitoring Service Reliability
      3. Retrieving Service Properties
        1. Enumerating Service Properties
        2. Identifying the Services Running in a Process
      4. Changing Service State
        1. Determining Which Services Can Be Stopped or Paused
        2. Stopping or Pausing Services
        3. Starting or Resuming Services
      5. Enumerating Dependent and Antecedent Services
        1. Enumerating Dependent Services
        2. Enumerating Antecedent Services
        3. Stopping and Starting Dependent Services
      6. Configuring Services
        1. Configuring Service Start Options
        2. Configuring Error Control Codes for Autostart Services
      7. Managing Service Accounts and Service Account Passwords
        1. Configuring Service Accounts
        2. Configuring Service Account Passwords
      8. Installing and Removing Services
        1. Installing Services
        2. Removing Services
    10. 16. Registry
      1. Registry Overview
      2. Managing the Registry
        1. Backing Up the Registry
        2. Reading Entry Values and Types
          1. Reading String-valued and DWORD-valued Entries
          2. Reading a Multistring-valued Entry
          3. Reading an Expanded String-valued Entry
          4. Reading a Binary-valued Entry
        3. Changing String-valued and DWORD-valued Entries
        4. Creating Registry Subkeys and Entries
          1. Creating a Subkey
          2. Creating String-valued and DWORD-valued Entries
          3. Creating Multistring-valued Entries
          4. Creating Expanded String-valued Entries
        5. Enumerating Keys, Subkeys, and Entries
          1. Enumerating Subkeys of a Key or Subkey
          2. Enumerating Entry Names, Values, and Data Types
        6. Deleting Subkeys and Entries
          1. Deleting Registry Entries
          2. Deleting a Registry Subkey
        7. Checking Registry Subkey Access Rights
      3. Monitoring the Registry
        1. Monitoring Subtree-Level Events
        2. Monitoring Subkey-Level Events
        3. Monitoring Entry-Level Events
  5. III. Scripting for the Enterprise
    1. 17. Creating Enterprise Scripts
      1. Enterprise Scripts Overview
      2. Retrieving Arguments
        1. Retrieving Arguments from a Text File
          1. Using a Text File as a Command-Line Argument
        2. Retrieving Arguments from a Database
        3. Retrieving Arguments from an Active Directory Container
      3. Displaying Output
        1. Displaying Tabular Script Output in a Command Window
        2. Displaying Data by Using Internet Explorer
          1. Displaying Data in a Web Page
            1. Clearing a Web Page
          2. Stopping a Script When Internet Explorer Is Closed
        3. Working with HTML Applications
        4. Displaying Script Output by Using the Tabular Data Control
          1. Sorting Data by Using the Tabular Data Control
          2. Filtering Data by Using the Tabular Data Control
          3. Sorting Data by Using a Disconnected Recordset
      4. Working with Databases
        1. Connecting to a Database
        2. Adding New Records to a Database
        3. Finding Records in a Recordset
        4. Updating Records in a Database
        5. Deleting Selected Records from a Database
        6. Deleting All Records in a Database Table
      5. Masking Passwords
        1. Masking Passwords by Using Internet Explorer
      6. Sending E-Mail
        1. Sending E-Mail from a Script
        2. Sending E-Mail Without Installing the SMTP Service
      7. Tracking Script Progress
        1. Tracking Script Progress by Using Internet Explorer
        2. Tracking Dynamic Script Progress by Using Internet Explorer
          1. Changing the Mouse Pointer
          2. Tracking Script Progress by Using an Animated .GIF
        3. Tracking Script Progress in a Command Window
      8. Managing Scheduled Tasks
        1. Enumerating Scheduled Tasks
        2. Creating Scheduled Tasks
        3. Deleting Scheduled Tasks
    2. 18. Scripting Guidelines
      1. Overview of Scripting Guidelines
      2. Using Naming Conventions
        1. Naming Scripts
        2. Naming Variables
          1. Using Hungarian Notation
          2. Guidelines for Naming Variables
          3. Reusing Variables
        3. Naming Constants
        4. Naming Functions and Procedures
      3. Constructing Scripts
        1. Choosing a Script Construction
        2. Creating a Script Template
        3. Using Functions and Procedures
          1. Calling Functions and Procedures
      4. Formatting Code
        1. Using White Space
          1. Using Blank Spaces Before and After Operators
          2. Using Blank Spaces in Parameter Lists
          3. Indenting Control Structures, Functions, and Procedures
        2. Setting Statement Breaks
          1. Limiting Each Line to a Single Statement
          2. Avoiding Single-Line If Then Statements
          3. Limiting Your Scripts to a Single Language
        3. Creating Scripts That Are Easier to Read
          1. Using the Proper Case
          2. Phrasing If Then Statements
          3. Using Boolean Expressions in Conditional Statements
          4. Using Parentheses in Mathematical Expressions
          5. Specifying Default Properties in Statements
        4. Commenting Scripts
          1. Adding Comments to a Script
          2. Formatting Comments
          3. Creating Script Headers
          4. Creating Function and Procedure Headers
          5. Creating Script Documentation by Using Comments
          6. Using Comments as a Debugging Aid
            1. Removing Debugging Comments
      5. Debugging and Troubleshooting Scripts
        1. Adding a Trace Routine to a Script
        2. Incrementally Running a Script
        3. Turning Off Error Handling as a Debugging Tool
      6. Testing Scripts
  6. System Requirements
  7. Faucet-Handle Puller

Product information

  • Title: Microsoft® Windows® 2000 Scripting Guide
  • Author(s):
  • Release date: December 2002
  • Publisher(s): Microsoft Press
  • ISBN: 9780735618671