<script> Element (Windows Script Host)

Contains script that defines the behavior of a Windows Script (.wsf) file.

                      <script language="language" [src="strFile"]>
     script here
</script> 

Arguments

  • language
    The name of the scripting language, such as VBScript or JScript, used in the script block.

  • strFile
    The name of the script file to include into the script block.

Remarks

If XML validation is not enabled, the XML parser ignores all lines inside the <script> element. However, if XML validation is enabled by including the <?XML?> element at the top of the Windows Script (.wsf) file, the XML parser can misinterpret greater than (>), less than (<), and other symbols used in script as XML delimiters.

If you are creating a file that conforms closely to XML syntax, you must ensure that characters in your script element are not treated as XML-reserved characters. To do this, enclose the actual script in a <![CDATA[ ... ]]> section. This applies to all data blocks - <example>, <description>, and <resource>. All may need CDATA markers if <?XML?> is specified and if they include XML-reserved characters.

Note

Do not include a CDATA section unless you also include the <?XML?> declaration.

Example

The following example incorporates two jobs into one .wsf file, using two different scripting languages:

<package>
   <job id="DoneInVBS">
   <?job debug="true"?>
      <script language="VBScript">
         WScript.Echo "This is VBScript"
      </script>
   </job>

   <job id="DoneInJS">
   <?job debug="true"?>
      <script language="JScript">
         WScript.Echo("This is JScript"); 
      </script>
   </job>
</package>

See Also

Reference

<runtime> Element (Windows Script Host)

<named> Element

<description> Element (Windows Script Host)

<example> Element

<object> Element (Windows Script Host)

<package> Element (Windows Script Host)

<resource> Element (Windows Script Host)

<?XML?> Element