Please enable JavaScript to view this site.

PrimalScript - Help Manual

Navigation: Windows Script Host Features

Windows Script Files (WSF)

Scroll Prev Top Next More

A Windows Script File (.wsf) is a special, XML-formatted file that can contain multiple scripts (referred to as jobs), define command-line arguments, and more. Using the WSF format, you can essentially write your own command-line tools using VBScript or JScript. Although the XML format is complex, you don't need to worry about it because PrimalScript handles it all behind the scenes—allowing you to focus on your scripts.

In this topic we will show you how to create a WSF project, and explain the WSF workspace, properties, and code.

Starting a WSF

A WSF is a special kind of PrimalScript project.

To create a WSF project

1.Click File > New Project > Windows Script Host Projects > Windows Script File.

2.Enter a name and location for your new file and specify a name for the workspace.

3.Specify the name of the script, its location, the name of the first job in the WSF, and the scripting language.

4.Add objects to the job.

 To add objects that are not on the default list, click Browse.

 By referencing the objects that your scripts will use, you can use any constants defined in the objects' type libraries.

5.Add other references.

6.Add additional files to the job. To direct PrimalScript copy these files to the folder for you, click Copy files to script folder.

 

WSF Workspace

The WSF is part of a special PrimalScript workspace. You can add additional scripts—or jobs—to the workspace.

To add additional scripts or jobs to the workspace

Right-click the top-level workspace item in the Workspace Browser and select Add new job to workspace.

You can also open the workspace (that is, the WSF file) as a text file. Doing so provides access to the raw XML formatting as well as the script code of the jobs contained in the workspace.

You can also switch back to the workspace by right-clicking in the editing pane.

The context menu also offers options to add the workspace to source control (or, if it's already been added, check it in or out).

The Workspace Browser provides the key to managing the file. In addition to the actions available by right-clicking the top-level workspace item, you can also right-click a job (the next level of item), or any of the items within a job.

Right-clicking a job (such as "WindowsScript," shown here) gives you more options:

Right-clicking other objects—such as objects, references, or scripts—allows you to remove or rename them, as appropriate.

 Each WSF file or workspace can contain multiple jobs. Each job can contain one or more scripts, files, references, objects, and so forth.

To execute the final WSF and run a specific job

Run filename.wsf //job:jobid.

WSF Properties

Each job within a WSF workspace has a set of properties. These include the job's name (or ID) which is used to reference the job when running the final WSF.

The job can also have a text description which describes what the job does. If the WSF is run with only a /? argument, the description is part of what is automatically displayed.

A job can also have a usage explanation and an example. Both are textual fields that embed information within the job for future reference. Finally, jobs can have zero or more arguments. These are defined command-line arguments which can be accessed within the job's scripts via the WScript.Arguments object.

Arguments have a description, or name. For example, the argument shown here would be accessed from the command line like this: multicomputer.wsg /list:listname, using the argument's name. Arguments can also have a line of help text which is displayed as part of the automatic /? feature. Finally, arguments have a type. The type can be string, Boolean (meaning True or False) or simple. Simple arguments are simply specified or not; they are not given a value. For example, /verbose is an example of a simple argument: either it's specified or it isn't.

WSF Code

Script code is included within the WSF normally using the PrimalScript code window. PrimalScript handles the XML formatting necessary to enclose the script within its job, and the job within the overall WSF.

 

 

See also:

Windows Script Components

Script Signing

Script Encoding

Getting Help

 

SAPIEN Technologies, Inc. provides administrative tools to support all of your Windows scripting needs.