Home > Store

Windows Script Host

Register your product to gain access to bonus material or receive a coupon.

Windows Script Host

  • By
  • Published Feb 22, 2001 by Pearson.

Book

  • This product currently is not for sale.
Not for Sale

Description

  • Copyright 2001
  • Dimensions: K
  • Pages: 384
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-028701-6
  • ISBN-13: 978-0-13-028701-4

Automate Windows system administration, application control, file management, and more!

  • Scripting solutions for Windows 2000, Windows 9x, and Windows ME
  • Covers both VBScript and JScript
  • Step-by-step coverage of cre ating, running, scheduling, and distributing scripts
  • System administration, application control, file management, messaging, database access, and more
  • Creating high-performance WSH script components
  • Covers both VBScript and J Script!
  • Syntax, data storage, operators, strings, dates, times, objects, error handling, and more
  • Automating system administration, file management, database access, and messaging
  • Creating high-performance WSH components
  • Extending Windows' power by scripting Microsoft Office components
  • Appendices include detailed VBScript and JScript references
  • For every intermediate to advanced-level Windows user and administrator

Microsoft's W indows Script Host (WSH) offers system administrators and users powerful opportunities to save time and improve efficiency. In Windows Script Host, expert developer and best-selling author Peter G. Aitken covers WSH from start to finish, giving you all the skills you need to automate a wide range of system, application, and file-related tasks on Windows ME/9x and Windows 2000/NT platforms.

Aitken offers in-depth coverage of both widely used WSH scripting languages — VBScript and JSc ript. You'll start by mastering the Windows file system and scripting object models. Next, you'll learn the most effective ways to run, schedule, and distribute scripts. Once you've mastered the basics, Aitken presents practical techniques for scripting v irtually every aspect of the Windows environment, from messaging to file management, database access to system and Web administration.

Aitken presents step-by-step coverage of testing and debugging WSH scripts, demonstrates how to create fast, efficient Windows Script Components, and even shows how to extend Windows' power by scripting Microsoft Office components.

WSH gives you greater control over Windows than ever before. With Peter G. Aitken's help, you'll master that power—and dynamically improve your productivity every day you run Windows!

Sample Content

Table of Contents

(NOTE: Each chapter ends with Overview.)

1. Windows Script Host Fundamentals.

Background. Unix Scripting. The DOS Batch Language. Windows Scripting. How WSH Works. What Can WSH Do? WSH Operation. Scripting Technology. Two Scripting Utilities. WSH Languages. WSH and Objects.



2. The WSH Object Model.

Objects. Object References. Object Properties. Object Methods. Collections. The WshCollection Object. The FileSystemObject. The Dictionary Object. The Wscript Object. Obtaining Host Information. Script Interactivity. Terminating a Script. Setting a Timeout. Working with Objects. The WshShell Object. The WshEnvironment Object. The WshSpecialFolders Object. Working with Shortcuts. Displaying Popup Messages. Working with the Registry. Running Programs. The WshNetwork Object. Obtaining User Information. Working with Printers. Managing Network Drives.



3. Creating, Running, and Scheduling Scripts.

Creating Your Scripts. Online Documentation. Running Scripts. Script Shortcuts. Scheduling Scripts.



4. Working with Script Arguments, .WSH Files, and Web.

Scripting. Script Arguments. WSH Files. WSH and Web Scripting.



5. Testing and Debugging Your Scripts.

Catching Script Errors. Syntax Errors. Run-Time Errors. Bugs. Debugging Your Scripts. The Script Debugger. Using the Debugger.



6. VBScript: Syntax, Data Storage, and Operators.

Introduction to VBScript. Comparison with Visual Basic. Syntax Fundamentals. Comments. Line Continuations. Data Storage. Object References. Determining Data Type. Arrays. Static Arrays. Dynamic Arrays. Variant Arrays. Operators. Assignment Operator. Arithmetic Operators. String Operators. Comparison Operators. Logical Operators. Operator Precedence and Parentheses.



7. VBScript: Program Control and Procedures.

Conditional Statements. If… Then… Else. Select Case. Loop Statements. For…. Next. For Each… Next. Do…Loop. While…Wend. Infinite Loops. Procedures. Types of Procedures. Defining a Procedure. Passing Arguments to Procedures. Variables in Procedures. Calling Procedures.



8. VBScript: Working with Text, Numbers, Dates, and Times.

Text Manipulation. Asc. Chr. Filter. InStr, InStrRev. InStrRev. Join. LCase, Ucase. Left, Mid, Right. Len. LTrim, RTrim, Trim. Mid (function). RegExp. Right. Rtrim. Space. Split. String. StrComp. Trim. Ucase. Working With Numbers. Using Dates and Times. Date and Time Representation. Getting the Current Date and Time. Creating Dates and Times. Adding and Subtracting Dates and Times. Getting Date and Time Information. Formatting Dates and Times.



9. VBScript: User Interaction, Error Handling, And Miscellaneous Topics.

Interacting with the User. The MsgBox Function. InputBox. Error Handling. Other Topics. Eval. Execute and ExecuteGlobal.



10. JScript: Basic Syntax, Data Storage, and Operators.

Introduction to Jscript. Comparison with Java. Syntax Fundamentals. Comments. Data Storage. Constants. Variables. Data Types and Coersion. Object References. Arrays. JScript Operators. The Assignment Operators. The Arithmetic Operators. The Increment and Decrement Operators. The Comparison Operators. The Logical Operators. String Operators. Conditional Expressions. Operator Precedence and Parentheses.



11. JScript: Conditional Statements, Loops, and Functions.

Conditional Statements. If…Else. Switch. Loop Statements. For. While. Do…While. The Continue Statement. The With Statement. Functions. Defining a Function. Variables in Functions. Calling a Function.



12. JScript: Strings, Numbers, Math, Dates, and Times.

The String Object. The Split Method. Working with Regular Expressions. The Number Object. The Math Object. Dates and Times.



13. JScript: Built-in Objects, User Interaction, and Error Handling.

JScript Objects. The Boolean Object. The Enumerator Object. The Function Object. The VBArray Object. User Interaction. Error Handling. The Error Object. Try…Catch. The Throw Statement.



14. WSH 2.0 and WSF Files.

Using WSF Files. XML and WSF Files. The <script> Tag. The <job> and <package>Tags. The <object> Tag. The <reference> Tag. Importing Files. XML Compliance. XML Errors and Debugging.



15. File Access and Management.

The Scripting Run-time Library. File Management. Copying and Moving Files. Copying and Moving Folders. Creating Folders. Deleting Files and Folders. Seeing if a Drive, Folder, or File Exists. Obtaining Object References. Working with the Drives Collection and Drive Object. Working with the Folders Collection and Folder Object. Working with the Files Collection and File Object. Other FileSystemObject Methods. File Access. The TextStream Object. A TextStream Demonstration.



16. Creating Windows Script Components.

Defining a Class. Creating Class Instances. Defining Class Properties. Defining Class Methods. Defining Private Class Information. Procedural Class Properties. Defining a Default Class Property. Using a Class in Multiple Scripts. A Class Example.



17. Database Access with Scripting.

Database Fundamentals. Database Technologies. Active Data Objects. Creating a Connection. Creating a Connection String. Recordsets. Creating a Recordset. Working with Recordsets. Accessing Field Data. Moving through a Recordset. Modifying Recordset Data.



18. Scripting Microsoft Office Components.

The Office Object Model. The Word Object Model. The Document Object. Manipulating Document Content. Other Document Properties and Methods. The Excel Object Model. The Workbook Object. The Worksheet Object. Validating Object References.



19. Messaging With WSH.

Scripts and Messaging. Some E-mail Background. Scripting CDO. Sending a Message with CDO. Reading Mail with CDO. Scripting Microsoft Outlook. The NameSpace Object. Manipulating Folders and Items. Working with Mail Messages.



20. Using WSH For Administrative Tasks.

Mapping Network Drives. Automating LogOn Scripts. Updating Files. Creating Folders.



21. A Script Programmer's Library.

Installing Files from a CD. Obtaining Information about a Database. Printing from a Script.



Appendix A. VBScript Constants.

Color Constants. Comparison Constants. Date and Time Constants. Date and Time Format Constants. Miscellaneous Constants. MsgBox Constants. String Constants.



Appendix B. VBScript Keywords.


Appendix C. ASCII Character Codes.


Appendix D. VBScript Error Codes.


Appendix E. JScript Reserved Words.

Current Reserved Words. Future Reserved Words. Words to Avoid.



Appendix F. JScript Error Codes.


Appendix G. WSH Resources on the Internet.


Index.

Preface

Introduction

The Windows Script Host, or WSH, is a wonderful tool that is available to all users of the Windows operating system. In a nutshell, WSH is used to create scripts that automate operating system-related tasks. Which tasks are these? Anything you do with the Windows operating system, as opposed to an application program, falls into this category. Examples include copying and deleting files, logging onto network drives and printers, and executing programs. But WSH is not limited to operating system tasks - thanks to Microsoft's Component Object Model, scripts can also control many applications programs, such as Word and Excel. Almost anything you can do sitting at your computer's keyboard, you can also program a script to do for you.

So, what's the big deal? There are two factors:

  • Saving time. With a couple of clicks, you can execute a script that carries out a complex series of action that would take a considerable time to perform manually.
  • Preventing errors. Once tested and debugged, a script will carry out a precise sequence of actions error-free every time. Few people can say the same thing about their keyboard skills!

Either of these factors by itself would make a strong argument for scripting. Together, they are overpowering. Any Windows user who has gone beyond casual computing is a candidate to benefit from using WSH. Network administrators and other computer professionals can derive even more benefit.

Who This Book Is For

The intended audience for this book is anyone who wants to automate repetitive or time-consuming tasks under the Windows operating system. This includes both computer users, for whom the computer is a tool, as well as network professionals and systems administrators, who are responsibile for maintaining computer systems used by others. I assume no prior knowledge on the part of the reader beyond a reasonable familiarity with Windows. Specifically, no programming experience is needed. If, however, you do have some programming experience, certain parts of the book will likely go faster for you.

What You Need

The requirements for using this book are quite simple: a computer running Windows 95, 98, ME, NT 4.0, or 2000. As you will learn in Chapter 1, WSH is installed along with some of these operating systems, but must be installed separately with others (Windows 95 and NT). Details on obtaining the free install are also included in Chapter 1.

Resources

You will find my Web page for this book at this URL:

http://www.pgacon.com/scripthost.htm

This page lets you download a compressed archive containing all of the book's scripts, and there is also a link for reporting any errors, problems, or suggestion. I will also post a list of corrections and updates as they become available. Additional Internet resources for the Windows Script Host programmer can be found in Appendix 7.

Peter G. Aitken
Chapel Hill, North Carolina
January 2001

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020