WSH exposes a relatively small but very significant portion of the functionality of the 32-bit Windows family of operating systems. In addition, WSH allows you to tap into other object models (such as the FileSystemObject object model provided by the Scripting Runtime library) that allow you to access additional features of either the operating system or individual applications.
The advantage of any script is that it allows repetitive tasksincluding complex ones that require multiple stepsto be performed more or less automatically. This makes scripting suitable for batch operationsthat is, for repetitive operations that do not require user intervention. In addition, if you are writing your scripts in VBScript, you can allow user interaction through the standard VBScript InputBox andMsgBox functions, as well as by instantiating components that support more sophisticated forms of interaction. Support for user interaction enhances the scripting environment's flexibility and increases the range of applications for which it is suitable.
Although the flexibility and power of WSH means that its actual uses are limited only by the imagination, we can nevertheless identify some areas in which WSH clearly excels:
Access to network resources
Although Windows makes automatic (and therefore more or less permanent) access to network resources at logon very easy, transitory access to network resources is not. WSH can be used to connect to network drives and printers for a short period, perform some operation, and then disconnect from the network resource.
A single script that is run locally on the user's machine or that is run from the system administrator's system and iterates network systems can enormously facilitate the tasks of administering a networked system.
Simple installation scripts
If your installation routine needs merely to check available disk space, determine whether any files are likely to be overwritten, copy some files, and add some registry settings, writing a WSH script can be as effective as a professional installation program while involving much less overhead.
By instantiating the FileSystemObject object, you can gain access to the local computer's filesystem, including attached network drives. This allows you to perform repetitivefile operations, as well as to determine the status, capability, and storage space available on individual drives.
Using WSH and VBScript, you can access the object model of an application program or a system service to perform some repetitive operation. For instance, you might use CDO to send a batch of emails with Microsoft Outlook, use Microsoft Word and Access to print mailing labels, or use Microsoft Excel to update monthly sales data and print the results in chart form.
Part I: The Basics
Data Types and Variables
Error Handling and Debugging
VBScript with Active Server Pages
Programming Outlook Forms
Windows Script Host 5.6
VBScript with Internet Explorer
Windows Script Components
Part II: Reference
Part III: Appendixes
Appendix A. Language Elements by Category
Appendix B. VBScript Constants
Appendix C. Operators
Appendix E. The Script Encoder