Jump to content

Windows Script File

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 59.97.34.176 (talk) at 07:24, 30 April 2009. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Windows Script File
Filename extension
.wsf
Internet media typetext/xml
Developed byMicrosoft
Type of formatScripting
Container forScripts

A Windows Script File (WSF) is a file type used by the Microsoft Windows Script Host. It allows mixing scripting languages such as Perl, Object REXX, Python, Kixtart, JScript, and VBScript within a single file. These types of scripts may also be used to link many other external scripts together using a src parameter on the <script> tag in a manner similar to HTML. Windows Script Files have the extension ".WSF". A WSF makes reference to each script module in a very basic XML hierarchy as shown below.

Error isolation

A WSF may be useful for isolating errors. Its modular nature prevents one script reference from interfering with another. Here is a WSF example with one module that produces an error and one that does not:

<job id="Partially works">
  '** This will not work
  <script language="VBScript">
        WScript.echo 4/0 ' Oh boy! You cannot divide by zero...
  </script>
  '** This will work... definitely...
  <script language="VBScript">
        WScript.echo "Hello Scripters!" & vbNewline & _
                     "Fantastic! It worked!"
  </script>
</job>

The first script module will produce a "divide by zero" error. Typically this would cause the script to end in the Windows Script Host but this modular method allows the script to continue and execute the second script module.