Windows Script File
Encyclopedia
A Windows Script File is a file type used by the Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 Windows Script Host
Windows Script Host
The Microsoft Windows Script Host is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features...

. It allows mixing the scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

s JScript
JScript
JScript is a scripting language based on the ECMAScript standard that is used in Microsoft's Internet Explorer.JScript is implemented as a Windows Script engine. This means that it can be "plugged in" to any application that supports Windows Script, such as Internet Explorer, Active Server Pages,...

 and VBScript
VBScript
VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It is designed as a “lightweight” language with a fast interpreter for use in a wide variety of Microsoft environments...

 within a single file, or other scripting languages such as Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

, Object REXX
Object REXX
The Object REXX programming language is an object-oriented scripting language initially produced by IBM for OS/2. It is a follow-on to and a significant extension of the "Classic Rexx" language originally created for the CMS component of VM/SP and later ported to MVS, OS/2 and PC DOS.On October 12,...

, Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

, or Kixtart
KiXtart
KiXtart is a free-format scripting language for Windows. It is described as a logon script processor and enhanced batch scripting language by the official website. Its name is a portmanteau of "kick start".-Overview:...

 if installed by the user. These types of scripts may also be used to link many other external scripts together using a src parameter on the
'** This will work... definitely...



The first script module will produce a "divide by zero" error. Typically this would cause the script to end in the Windows Script Host
Windows Script Host
The Microsoft Windows Script Host is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features...

 but this modular method allows the script to continue and execute the second script module.

Exposing constants

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's constants instead of having to declare them. In regular VBScript
VBScript
VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It is designed as a “lightweight” language with a fast interpreter for use in a wide variety of Microsoft environments...

 and JScript
JScript
JScript is a scripting language based on the ECMAScript standard that is used in Microsoft's Internet Explorer.JScript is implemented as a Windows Script engine. This means that it can be "plugged in" to any application that supports Windows Script, such as Internet Explorer, Active Server Pages,...

 files, you would be forced to declare a constant's value (outside of those that are internal to the Windows Script Host
Windows Script Host
The Microsoft Windows Script Host is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features...

) in order to use the constant. An example of this is shown below:

const adLockBatchOptimistic = 4
MsgBox "The value of ""adLockBatchOptimistic"" is " & _
adLockBatchOptimistic & ".", vbInformation,"adLockBatchOptimistic"

If your object documentation only refers to the constant's name and not the constant's value, you would have no way of knowing the value without the help of an Integrated development environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

 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
ActiveX Data Objects
Microsoft's ActiveX Data Objects is a set of Component Object Model objects for accessing data sources. A part of MDAC, it provides a middleware layer between programming languages and OLE DB...

) Recordset
Recordset
A recordset is a data structure that consists of a group of database records, and can either come from a base table or as the result of a query to the table....

.











Running the above script from a file with a ".WSF" extension, such as one named "EnumerateConstantsADO.wsf", will produce the result shown in the picture at the right of this paragraph. 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
Visual Basic
Visual Basic is the third-generation event-driven programming language and integrated development environment from Microsoft for its COM programming model...

 program and run the same way as long as that program uses the same reference to ADODB.

See also

  • Active Scripting
    Active Scripting
    Active Scripting is the technology used in Windows to implement component-based scripting support. It is based on COM and allows installation of additional scripting engines in the form of COM modules.-Uses and history:The Active Scripting technologies were first released in 1996, with the...

  • JScript
    JScript
    JScript is a scripting language based on the ECMAScript standard that is used in Microsoft's Internet Explorer.JScript is implemented as a Windows Script engine. This means that it can be "plugged in" to any application that supports Windows Script, such as Internet Explorer, Active Server Pages,...

  • Shell script
    Shell script
    A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...

  • VBScript
    VBScript
    VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It is designed as a “lightweight” language with a fast interpreter for use in a wide variety of Microsoft environments...

  • HTML Application
    HTML Application
    An HTML Application is a Microsoft Windows program whose source code consists of HTML, Dynamic HTML, and one or more scripting languages supported by Internet Explorer, such as VBScript or JScript. The HTML is used to generate the user interface, and the scripting language is used for the program...

  • Windows PowerShell
    Windows PowerShell
    Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework...

  • Windows Script Host
    Windows Script Host
    The Microsoft Windows Script Host is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features...


External links

  • Using Windows Script Files - From Microsoft's
    Microsoft
    Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

     website
  • Scripting Languages Available in the Script Center - From Microsoft's
    Microsoft
    Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

    website
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK