ScriptIt.doc

(81 KB) Pobierz
Page 1

®

 

Windows NT® Server

Server Operating System

The Microsoft ScriptIt Utility

White Paper

Abstract

This White Paper describes Microsoft® ScriptIt, a tool for automating interactive software installations and system configuration tasks. ScriptIt can be used to start a process, monitor the window titles of active processes, and, when appropriate, send a set of keystrokes to the correct window. The keystrokes can be predetermined or they can be determined at run time. ScriptIt can be configured to differentiate (and respond appropriately) between multiple windows that have the same title bar but different instructional text.

Note that ScriptIt is not a traditional scripting language and does not offer many of the traditional programming language constructs. The ScriptIt command must be started by a user with sufficient security privileges to perform the designated installation or configuration task.

Important: Microsoft does not provide technical support for scripts prepared with the ScriptIt tool. Consequently, it is important that you test your scripts thoroughly before using them in a production environment.

 


© 1998 Microsoft Corporation. All rights reserved.

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.

This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.

Microsoft, the BackOffice logo, FrontPage, JScript, MS-DOS, Visual Basic, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

Other product or company names mentioned herein may be the trademarks of their respective owners.

Microsoft Corporation • One Microsoft Way • Redmond, WA 98052-6399 • USA

0398


 

Contents

Introduction              1

Document Conventions              1

Using ScriptIt              2

Script File Format              3

The [SCRIPT] Section              3

Run and Runwait              3

Title and Title+text              5

MkFile              10

REM              11

Some Sample [SCRIPT] Sections              11

The [ADLIB] Section              12

Sample Script with [ADLIB] Section              12

sample SCRIPTs              14

Installing FrontPage97 Server Extensions              15

Installing Active Server Pages              15

Installing Index Server              15

Installing Compaq's Support Software Diskette (SSD)              15

Installing Web Administration              15

For More Information              16

 




Introduction

Microsoft® ScriptIt is a command-line utility for automating interactive software installations and system configuration tasks. ScriptIt works by monitoring the window titles of active processes. When it finds a window with which it should interact, it sends a set of keystrokes to that window. ScriptIt uses the window title or a combination of the window title and text that appears on controls within the window to identify the window that will receive the keystrokes. The use of the window title combined with text allows ScriptIt to differentiate between multiple windows that have the same title bar.

Important: Microsoft does not provide technical support for scripts prepared with the ScriptIt tool. Consequently, it is important that you test your scripts thoroughly before using them in a production environment.

Document Conventions

This White Paper uses the following document conventions:

monospace

Indicates source code, structure syntax, examples, user input, and program output.

Bold

Indicates a function, structure, macro, interface, method, data type, or other keyword in the programming interface or programming language.

Italic

Indicates a placeholder, most often a function or method parameter; these placeholders represent the information that the user must supply or implement. In addition, italics are used to highlight the first use of terms and to emphasize meaning.

UPPERCASE

Indicates a flag, return value, or property. In addition, uppercase letters indicate registers and terms used at the operating system command-level.

[ ]

Square brackets indicate the beginning of a script file section.

< >

Angle brackets indicate optional function or method parameters. Type only the syntax within the brackets, not the brackets themselves.

Using ScriptIt

To use ScriptIt, you need the ScriptIt script processing engine, ScriptIt.exe, and a valid script file as described in this document. To use ScriptIt to automate a software installation or system configuration change, the user that launches ScriptIt must be logged on with sufficient security privileges to perform the designated installation or configuration task.

To start the ScriptIt utility,  type the following from the Run command:

SCRIPTIT script file

 

where script file is a text file in .ini file format. This script file uses .ini file keys to identify the window titles that ScriptIt should interact with, and specifies the keystrokes that ScriptIt sends to these windows as .ini file key values. For example, the script file entries:

run=notepad.exe

Untitled - Notepad=Hello World

 

launch an instance of Notepad and then send the string "Hello World" to the open Microsoft Notepad window with the title bar Untitled – Notepad.

Note that ScriptIt is not a traditional scripting language and does not offer many of the traditional programming language constructs (such as if, then, else, while, gosub, and so forth). The remainder of this paper describes the ScriptIt script file structure and variables, and provides sample code and examples of valid script files.

Script File Format

The basic ScriptIt script file can have the following format and line types:

[SCRIPT]

run=command

runwait=command

WindowTitle=keystrokes

WindowTitle<+text>=keystrokes

mkfile filename.ext=fileline

REM comment

 

[ADLIB]

WindowTitle=keystrokes

WindowTitle<+text>=keystrokes

The [SCRIPT] Section

Each script file begins with the section tag [SCRIPT]. [SCRIPT] tells ScriptIt where to begin processing the script file. Any text above the [SCRIPT] tag is ignored and can be used to document your script. Lines in the [SCRIPT] section are processed sequentially.

Within the [SCRIPT] section, ScriptIt recognizes four types of .ini file lines:

·         Run lines (run and runwait), which start executables, run valid MS-DOS® operating system commands, and interpret valid WinBatch commands.

·         Window title lines (title and title+text), which identify an instance of a window and send the designated keystrokes.

·         Make file lines (mkfile), which cause the script to open a new file as specified by filename and write lines of text to it as specified by fileline.

·         Remarked lines ( REM), which allow script lines to be deactivated and documented.

The optional [ADLIB] section provides instructions for ScriptIt to use when the setup program displays a window or dialog box that is not part of a normal scripted process and therefore not specified in the [SCRIPT] section. Entries in the [ADLIB] section allow ScriptIt to respond appropriately to errors or exceptions that occur during the processing of the [SCRIPT] section. Lines in the [ADLIB] section can also be used to accommodate setup programs that behave differently if they are run a second time on the same system. Lines that appear in this section are processed only if a matching window is displayed; otherwise, they are ignored.

Run and Runwait

Run lines (run and runwait) execute command lines. ScriptIt handles run and runwait lines by parsing and executing the value(s) to the right of the equal sign. For example, the line

run=notepad.exe

 

causes ScriptIt to start Notepad and then continue with processing the next line in the [SCRIPT] section.


A runwait line is similar to a run line except that ScriptIt allows the runwait command-line to complete processing before proceeding to the next line in the [SCRIPT] section. For example, the line

runwait=notepad.exe

 

starts Notepad, but does not go on to the next script file line until that instance of Notepad is closed.

If the command to be run is an executable or batch file, the run or runwait line needs both a file name and extension. In addition, if the command you wish to run is not in the path, you must also specify a fully qualified path. If the command is an internal command such as for, echo, or type, the command-line must start with the left quotation mark (`). The left quotation mark directs ScriptIt to pass the command line to the %ComSpec% command interpreter for execution.

Syntax

 

run= <`> <@> fileName.ext

runwait= <`> <@> fileName.ext

 

With run or runwait, the value to the right of the equal sign can take various forms. If environment variables appear in the command line, ScriptIt substitutes the %envVar% string with the value of the appropriate environment variable.

In addition to environment variable expansion, ScriptIt uses the first character to the right of the equal sign to determine how to evaluate the string at run time. The following paragraphs document the parameters that ScriptIt recognizes and describe how ScriptIt responds in each case.

The parameters are as follows:

fileName.extension

If the value to the right of the equal sign begins with the name of the command you wish to run, ScriptIt treats the line as if it had been typed at the Run command dialog box. (This is the default.)

`

When a single left quotation mark (`) is the first character to the right of the equal sign, ScriptIt assumes the command that follows is an internal command, such as for, echo, or type. ScriptIt prefaces the command line with the value of %ComSpec% /C before executing the command line.

@

When the @ sign is the first character to the right of the equal sign, ScriptIt interprets the remainder of the line as a WinBatch command. (WinBatch is a scripting language written by Wilson Window Ware. It has more than 400 functions that can be used to interrogate and manipulate Microsoft Windows® 95 and Microsoft Windows NT® operating systems.)


Title and Title+text

The second type of .ini file line is known as a title line. ScriptIt handles title lines by locating an active window with a window title that matches the key name exactly—identical case and spacing is required. ScriptIt then sends the values to the right of the equal sign to that window as keystrokes.

While case and spacing is important in matching window titles, you do not need to specify the entire window title. ScriptIt can match partial window titles. For example, you could use “Calculator” or “Calc” to  match the Calculator window. A tilde (~) character at the beginning of the title line allows you to match window titles that contain the specified string anywhere in the window title. For example: “~Notepad” will match a window title that contains the string “This is my Notepad window”. A tilde (~) character at the end of the title line allows you to specify an exact window title match. For example: “Calc~” will only match a window title who’s title is “Calc”. It will not match “Calculator”. A tilde (~) at the beginning and end of the title line will allow you to match a window title that contains the specified string at the end of the window title. For example: “~Notepad~” will match the window title “Notepad” and the window title “Untitled – Notepad”, but not “Notepad – MyNote”.

 

When there are multiple windows open with the same window title, you can uniquely identify a specific window by using a plus sign (+) combined with text that appears on one of the controls in the target window. This is referred to as a title+text line. For example, if there are two instances of the Windows Calculator accessory application (Calc.exe) running, the line

Calculator+999=*9=

 

sends the string *9= to the Calculator window instance that has 999 displayed in the input box. This results in the total 8991 (999 *9). The other instance of the Calculator receives no keystrokes.

Note that ScriptIt cannot detect all text in all windows. To determine if ScriptIt can see specific text, run ScriptIt /reveal and then use ALT+TAB to go to the window you wish to analyze. The ScriptIt window will list the window title and any text that it can see on controls within that window. You can use ScriptIt /reveal2 if the window you want to analyze is a full screen window that covers up the ScriptIt /reveal window. ScriptIt /reveal2 first enumerates all existing windows, hidden or visible. From that list, select the window you wish to analyze, and then click OK. ScriptIt responds by listing all of the text that it can see on that window.

If ScriptIt doesn't find a window title that matches the current title line in the script file, ScriptIt will wait indefinitely until a matching window appears. This behavior allows ScriptIt to avoid the timing problems that affect other graphical user interface (GUI) automation tools.

Syntax

 

WindowTitle<+text>= <@> <`> <#> <~ > keystrokes

 

As with the run line syntax, the first character to the right of the equal sign of a title line is evaluated at run time. The major difference is that the result is sent to the designated window as keystrokes instead of being executed. Also, as with run lines, any title string value enclosed in percent (%) signs is expanded to the value of the corresponding environment variable before it is sent to the window as keystrokes.

The parameters are as follows:

WindowTitle

This is the title of the target window (required).

...
Zgłoś jeśli naruszono regulamin