WSF - Windows Script File XML Format
This section describes the WSF (Windows Script File) XML format. Multiple script jobs with different scripting language can be defined in a single WSF file.
WSH can run a VBScript code file directly.
But it also supports an XML file format called .WSF (Windows Script File).
WSF file offers an XML structure to define script jobs and group jobs into a package.
WSF supports the following basic XML elements:
- "package" - The root element of WSF file.
- "package.job" - The job element defines a script job with the "id" attribute.
- "package.job.script" - The script element inserts a segment of script code in the language
specified in the "language" attribute.
Here is a tutorial example of a WSF file:
<?xml version="1.0" encoding="UTF-8"?>
- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
WScript.Echo "Hello world! - VBScriptJob"
WScript.Echo("Hello world! - JScriptJob");
sName = "MixedJob"
WScript.Echo("Hello world! - "+sName);
Jobs defined in this WSF file can be executed with WSH hosts as shown below:
C:\herong>cscript //Job:VBScriptJob Windows_Script_File.wsf
Hello world! - VBScriptJob
C:\herong>cscript //Job:JScriptJob Windows_Script_File.wsf
Hello world! - JScriptJob
C:\herong>cscript //Job:MixedJob Windows_Script_File.wsf
Hello world! - MixedJob
- "//Job:..." option must be used to run a job defined in a WSF file, except for the first job.
- "MixedJob" shows that multiple script code segments of different language can be used together
to perform a single task.
Table of Contents
About This Book
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
Creating Your Own Classes
IE Web Browser Supporting VBScript
IIS ASP Server Supporting VBScript
►WSH (Windows Script Host)
What is WSH (Windows Script Host)?
"csript.exe/wscript.exe" Command Version and Options
Running VBScript Code Files
"WScript" Runtime Object Hierarchy
"oShell.Exec(cmd)" - Running System Command with a Script
►WSF - Windows Script File XML Format
Full Version in PDF/EPUB