Chapter 5. Creating Scripts and Scripting Files

Windows Script Host (WSH) provides several different ways to work with Windows scripts. The easiest technique is to create scripts using only a single scripting language and then save the script using the appropriate extension for the scripting engine. If you use VBScript, you save the script with the .vbs extension. If you use JScript, you save the script with the .js extension. Unlike script files used with Web pages, WSH script files don't need to contain any special markup or any kind of instructions.

You can also combine multiple types of scripts in a batch script. With batch scripts, you can use a single file and save it with the .wsf file extension. Because batch scripts can use scripts written in multiple scripting languages, you must somehow identify the type of scripts you are using and other important aspects of these scripts. You do this using markup tags written in XML (Extensible Markup Language). Don't worry — you don't need to become an XML or HTML expert to work with batch scripts. However, you do need to learn a bit about the markup tags available for use with WSH.

Running Scripts

You run scripts using the scripting hosts provided by WSH. These scripting hosts are:

  • WScript: WScript is a scripting host with GUI controls for displaying output in pop-up dialog boxes and is used primarily ...

Get Microsoft® PowerShell, VBScript and JScript® Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.