ShowUsage Method 

Makes a script self-documenting by displaying information about how it should be used.


object.ShowUsage

Parameters

  • object
    WScript Object.

Remarks

When you run the ShowUsage method, a help screen (referred to as the usage) appears and displays details about the script's command line options. This information comes from the runtime section of the *.WSF file. Everything written between the <runtime> and </runtime> tags is pieced together to produce what is called a "usage statement." The usage statement tells the user how to use the script.

Note

The usage can also be displayed using the /? switch.

Example

The following example demonstrates how to set up usage information in a *.WSF script file.

<job>

    <runtime>

        <description>This script reboots a server</description>

        <named

            name = "Server"

            helpstring = "Server to run the script on"

            type = "string"

            required = "true"

        />

        <example>Example: reboot.wsf /server:scripting</example>

    </runtime>

<script language="VBScript">



If WScript.Arguments.Count <> 1 Then

   WScript.Arguments.ShowUsage

   WScript.Quit

End If



</script>

</job>

The JScript code for the equivalent script block would be:

if (WScript.Arguments.length != 1)

{

   WScript.Arguments.ShowUsage();

   WScript.Quit();

}

Calling the ShowUsage method from this script results in the following output:

This script reboots a server

Usage: reboot.wsf /server:value



Options:



server : Server to run the script onExample:

reboot.wsf /server:scripting

Applies To:

Arguments Property (WScript Object)

See Also

Reference

WScript Object