<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Windows_Script_File</id>
	<title>Windows Script File - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Windows_Script_File"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Windows_Script_File&amp;action=history"/>
	<updated>2026-07-05T12:37:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Windows_Script_File&amp;diff=1310107&amp;oldid=prev</id>
		<title>~2025-40615-65: VBS and VB are different languages</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Windows_Script_File&amp;diff=1310107&amp;oldid=prev"/>
		<updated>2025-12-14T18:20:26Z</updated>

		<summary type="html">&lt;p&gt;VBS and VB are different languages&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox file format&lt;br /&gt;
| name = Windows Script File&lt;br /&gt;
| extension = &amp;lt;code&amp;gt;.wsf&amp;lt;/code&amp;gt;&lt;br /&gt;
| owner = [[Microsoft]]&lt;br /&gt;
| genre = Scripting&lt;br /&gt;
| container for = Scripts&lt;br /&gt;
}}&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;Windows Script File&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;WSF&amp;#039;&amp;#039;&amp;#039;) is a file type used by the [[Microsoft]] [[Windows Script Host]]. It allows mixing the [[scripting language]]s [[JScript]] and [[VBScript]] within a single file, or other scripting languages such as [[Perl]], [[Object REXX]], [[Python (programming language)|Python]], or [[Kixtart]] if installed by the user. These types of scripts may also be used to link many other external scripts together using a &amp;lt;code&amp;gt;src&amp;lt;/code&amp;gt; parameter on the {{tag|script|o}} tag in a manner similar to [[HTML]]. Windows Script Files have the extension &amp;lt;code&amp;gt;.WSF&amp;lt;/code&amp;gt;. A WSF makes reference to each script module in a very basic [[XML]] hierarchy as shown below, adhering to those standards outside the {{tag|script|o}} tags. Literal use of {{tag|script|c}} or {{tag|script|o}} inside your {{tag|script|o}} tags and similar challenges can be handled by the use of [[CDATA]], as shown within the examples.&lt;br /&gt;
&lt;br /&gt;
== Error isolation ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;aspx-vb&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;job id=&amp;quot;Partially works&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;!-- This will not work --&amp;gt;&lt;br /&gt;
   &amp;lt;script language=&amp;quot;VBScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;    &amp;lt;![CDATA[&lt;br /&gt;
         WScript.echo 4/0 &amp;#039; Oh, boy! You cannot divide by zero...&lt;br /&gt;
&amp;#039;    ]]&amp;gt;&lt;br /&gt;
   &amp;lt;/script&amp;gt;&lt;br /&gt;
   &amp;lt;!-- This will work... definitely... --&amp;gt;&lt;br /&gt;
   &amp;lt;script language=&amp;quot;VBScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;    &amp;lt;![CDATA[&lt;br /&gt;
         WScript.echo &amp;quot;Hello, Scripters!&amp;quot; &amp;amp; vbNewline &amp;amp; _&lt;br /&gt;
                      &amp;quot;Fantastic! It worked!&amp;quot;&lt;br /&gt;
&amp;#039;    ]]&amp;gt;&lt;br /&gt;
   &amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;lt;/job&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The first script module will produce a &amp;quot;divide by zero&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
== Mixed language support ==&lt;br /&gt;
&lt;br /&gt;
A Windows Script File supports multiple languages, as described on the [[Windows Script Host]] reference.  One of the features of this file format is that you may use more than one at once.  This means you can have one scripting language use code from another scripting language.  The most memorable example for long-time [[VBScript]] users is the use of Microsoft [[JScript]] to service a sort request for [[VBScript]] since it does not have a built-in sort function for an array of values.  [[VBScript]] users may write their own sort method or borrow one from an existing object like an ADO ([[ActiveX Data Objects]]) [[Recordset]] or a .NET ([[.NET Framework]]) [[ArrayList]], but the fastest way to sort an array is to use the method built into [[JScript]].  Here is a basic example of how that works:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;aspx-vb&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;!-- Mixing JScript and VBScript --&amp;gt;&lt;br /&gt;
 &amp;lt;job id=&amp;quot;SORT-VBScriptWithJScript&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;script language=&amp;quot;JScript&amp;quot;&amp;gt;&lt;br /&gt;
     function SortVBSArray(arr) {return arr.toArray().sort();}&lt;br /&gt;
   &amp;lt;/script&amp;gt;&lt;br /&gt;
   &amp;lt;script language=&amp;quot;VBScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;    &amp;lt;![CDATA[&lt;br /&gt;
     &amp;#039;** Fastest sort: call the Jscript sort from VBScript&lt;br /&gt;
     myData = &amp;quot;a,b,c,1,2,3,X,Y,Z,p,d,q&amp;quot;&lt;br /&gt;
     wscript.echo &amp;quot;Original List of values: &amp;quot; &amp;amp; vbTab &amp;amp; myData&lt;br /&gt;
     starttime = timer()&lt;br /&gt;
     sortedArray = SortVBSArray(split(myData,&amp;quot;,&amp;quot;))&lt;br /&gt;
     endtime=timer()&lt;br /&gt;
     jscriptTime = round(endtime-starttime,2)&lt;br /&gt;
     wscript.echo &amp;quot;JScript sorted in &amp;quot; &amp;amp; jscriptTime &amp;amp; &amp;quot; seconds: &amp;quot;  &amp;amp; vbTab &amp;amp; sortedArray&lt;br /&gt;
&amp;#039;    ]]&amp;gt;&lt;br /&gt;
   &amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;lt;/job&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The output looks like this, sorted by [[ASCII]] code sequence:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
Original List of values:        a,b,c,1,2,3,X,Y,Z,p,d,q&lt;br /&gt;
JScript sorted in 0 seconds:    1,2,3,X,Y,Z,a,b,c,d,p,q&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exposing constants ==&lt;br /&gt;
&lt;br /&gt;
Another very useful feature of a WSF is that the XML wrapper can be bound to an object reference or control so you can use that object&amp;#039;s constants instead of having to declare them.  In regular [[VBScript]] and [[JScript]] files, you would be forced to declare a constant&amp;#039;s value (outside those that are internal to the [[Windows Script Host]]) in order to use the constant.  An example of this is shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vbscript&amp;quot;&amp;gt;&lt;br /&gt;
const adLockBatchOptimistic = 4&lt;br /&gt;
MsgBox &amp;quot;The value of &amp;quot;&amp;quot;adLockBatchOptimistic&amp;quot;&amp;quot; is &amp;quot; &amp;amp; _&lt;br /&gt;
       adLockBatchOptimistic &amp;amp; &amp;quot;.&amp;quot;, vbInformation,&amp;quot;adLockBatchOptimistic&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If your object documentation only refers to the constant&amp;#039;s name and not the constant&amp;#039;s value, you would have no way of knowing the value without the help of an [[Integrated development environment]] to tell you what they equate to. By using the WSF reference declaration, you can use the constants without declaring their values.  The example below enumerates the values of several common constants in the ADO ([[ActiveX Data Objects]]) [[Recordset]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;aspx-vb&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;!-- WSF Example with Object Reference&lt;br /&gt;
Notes for this very formal example:&lt;br /&gt;
 CDATA is used to help the XML parser ignore &lt;br /&gt;
 special characters in the content of the script.  &lt;br /&gt;
 The CDATA open and close must be masked &lt;br /&gt;
 from VBScript by making them comments.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;package&amp;gt;&lt;br /&gt;
 &amp;lt;job id=&amp;quot;EnumerateConstantsADO&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;reference object=&amp;quot;ADODB.Recordset&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;script language=&amp;quot;VBScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;  &amp;lt;![CDATA[&lt;br /&gt;
    dim title, str, i&lt;br /&gt;
    ctecArray = Array(&amp;quot;adOpenUnspecified&amp;quot;,&amp;quot;adOpenForwardOnly&amp;quot;, _&lt;br /&gt;
                      &amp;quot;adOpenKeyset&amp;quot;,&amp;quot;adOpenDynamic&amp;quot;,&amp;quot;adOpenStatic&amp;quot;)&lt;br /&gt;
    title = &amp;quot;ADO Recordset Values for Constants&amp;quot;&lt;br /&gt;
    str = title &amp;amp; vbNewLine &amp;amp; vbNewLine&lt;br /&gt;
    str = str &amp;amp; &amp;quot;*CursorTypeEnum Constants*&amp;quot; &amp;amp; vbNewLine&lt;br /&gt;
    For i = 0 to ubound(ctecArray)&lt;br /&gt;
      str = str &amp;amp; Eval(ctecArray(i)) &amp;amp; vbTab &amp;amp; ctecArray(i) &amp;amp; vbNewLine&lt;br /&gt;
    Next&lt;br /&gt;
    str = str &amp;amp; vbNewLine&lt;br /&gt;
    str = str &amp;amp; &amp;quot;*LockTypeEnum Constants*&amp;quot; &amp;amp; vbNewLine&lt;br /&gt;
    ltecArray = Array(&amp;quot;adLockUnspecified&amp;quot;,&amp;quot;adLockReadOnly&amp;quot;, _&lt;br /&gt;
                      &amp;quot;adLockPessimistic&amp;quot;,&amp;quot;adLockOptimistic&amp;quot;, _&lt;br /&gt;
                      &amp;quot;adLockBatchOptimistic&amp;quot;)&lt;br /&gt;
    For i = 0 to ubound(ltecArray)&lt;br /&gt;
      str = str &amp;amp; Eval(ltecArray(i)) &amp;amp; vbTab &amp;amp; ltecArray(i) &amp;amp; vbNewLine&lt;br /&gt;
    Next&lt;br /&gt;
    MsgBox str, vbInformation, Title&lt;br /&gt;
&amp;#039;  ]]&amp;gt;&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;lt;/job&amp;gt;&lt;br /&gt;
&amp;lt;/package&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Running the above script from a file with a &amp;lt;code&amp;gt;.WSF&amp;lt;/code&amp;gt; extension, such as one named &amp;lt;code&amp;gt;EnumerateConstantsADO.wsf&amp;lt;/code&amp;gt;, will produce the result shown below:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;output&amp;quot;&amp;gt;&lt;br /&gt;
ADO Recordset Values for Constants&lt;br /&gt;
&lt;br /&gt;
*CursorTypeEnum Constants*&lt;br /&gt;
-1      adOpenUnspecified&lt;br /&gt;
0       adOpenForwardOnly&lt;br /&gt;
1       adOpenKeyset&lt;br /&gt;
2       adOpenDynamic&lt;br /&gt;
3       adOpenStatic&lt;br /&gt;
&lt;br /&gt;
*LockTypeEnum Constants*&lt;br /&gt;
-1      adLockUnspecified&lt;br /&gt;
1       adLockReadOnly&lt;br /&gt;
2       adLockPessimistic&lt;br /&gt;
3       adLockOptimistic&lt;br /&gt;
4       adLockBatchOptimistic&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In addition, using the object reference to expose the constants makes writing the script more like writing in a standard programming language.  In fact, the contents of the sample script, written in VBScript, will actually compile into a [[Visual Basic]] program and run the same way as long as that program uses the same reference to ADODB.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
*[[Active Scripting]]&lt;br /&gt;
*[[Shell script]]&lt;br /&gt;
*[[HTML Application]]&lt;br /&gt;
*[[PowerShell]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
*[https://web.archive.org/web/20160330040830/https://msdn.microsoft.com/en-us/library/15x4407c.aspx Using Windows Script Files] - From [[The Wayback Machine|The WayBack Machine&amp;#039;s]] archive of a page from [[Microsoft|Microsoft&amp;#039;s]] website&lt;br /&gt;
*[https://web.archive.org/web/20090315062650/http://www.microsoft.com/technet/scriptcenter/scripts/language.mspx Scripting Languages Available in the Script Center] - From [[The Wayback Machine|The WayBack Machine&amp;#039;s]] archive of a page from [[Microsoft|Microsoft&amp;#039;s]] website&lt;br /&gt;
&lt;br /&gt;
[[Category:Windows administration]]&lt;/div&gt;</summary>
		<author><name>~2025-40615-65</name></author>
	</entry>
</feed>