Extending Functionality with KiXtart

Extending Functionality with KiXtart

KiXtart is an independent script language developed by Ruud van Velsen of Microsoft Benelux. You find KiXtart at http://netnet.net/~swilson/kix/download.htm. It contains a logon script processor and a script language extension for Windows Server 2003. KiXtart lets you query information, set environment variables, modify the registry, and access the file system using a free-form language syntax with many functions that the default command-line prompt does not have.

The KiXtart package comprises several files. Only the main program (Kix32.exe) is needed for Windows Server 2003. It is recommended that the Kix32.exe program file be saved in a system directory that is already linked to the default path. In principle, Kix32.exe can be saved in the same directory as a KiXtart script to be executed. That is all the installation effort required.

KiXtart scripts are simple text files that can be invoked from the local hard drive or a network drive. If KiXtart is used for global logon scripts, Kix32.exe should be located in a network directory.

KiXtart is started by entering Kix32 in the command line or referencing Kix32 as a logon script. One or more script files can be set as Kix32 parameters.

Core Components

The KiXtart script language has three core components: commands, functions, and macros. It also uses basic operators and special syntax characters. All these are described in the KiXtart documentation delivered with the product.

KiXtart has a free-form language that is independent of capitalization. However, it has become customary to differentiate the core components by spelling—for example, capital letters for commands, initial caps for functions, and all lowercase for macros.


KiXtart commands perform actions such as deleting screen contents, setting text colors, changing font size, or connecting network drives. For instance, the Use command connects and disconnects a network resource.

Expressions for conditional situations are supported by command sequences, such as If—Else—Endif or Select—Case—Endselect. KiXtart supports nested If conditions. To control execution flow, the While—Loop and Do Until commands loop instructions until defined abort conditions are met causing the execution loop to be exited.

Additionally, Gosub or Goto commands can be used for jumping subroutines. The Run command allows executing external programs, and the Call command enables invoking of further KiXtart scripts, similar to the language syntax of standard command-line scripts.


Functions exceed command possibilities and usually need one or more expressions for parameters. The character strings can be included in single or double quotation marks.

Most functions return a character string or a numerical value. They also set the @error value to indicate possible problems that might prevent a script from running properly.

Let us now look at some functions that can handle important tasks for terminal servers.

  • AddPrinterConnection, DelPrinterConnection Adds or deletes printer connections

  • SetDefaultPrinter Determines a user’s default printer

  • AddProgramGroup, AddProgramItem Adds program groups and program icons

  • EnumLocalGroup, EnumGroup Determines the local and global groups to which a user belongs

  • InGroup Verifies whether a user belongs to a group

  • AddKey, DelKey Adds and deletes registry keys

  • LogEvent Writes messages in the systemwide Event Viewer log file

  • LogOff Forces a user to log off

  • MessageBox Displays a message box

  • CompareFileTimes, GetFileVersion Supports input and output at file level

  • SendMessage Sends a message to another computer

If a KiXtart script runs in user context, only personal program groups or user- specific areas of the registry can be modified. Only an administrator has extended permissions granted for relevant scripts.


KiXtart macros provide information such as network addresses or logon servers. The following table lists the most important macros.

Table 7.5: The Most Important KiXtart Macros




Network interface card address.


Date in YYYYMMDD format.


Day of the week.


Full name of the current user.


The TCP/IP address. The x in the macro references the number of the network interface card. The value can be 0-3. @ipaddress0 references the first network card. The return value consists of a character string in the decimal-point notation for IP addresses. Each octet can have a value from 000 through 255 (for example,


Logon domain.


Logon server.


Primary group to which the current user belongs.


Age of the current user’s password.


Current time.


User ID of the current user.


Name of the computer.

Basic Operators and Special Syntax Characters

KiXtart supports the logical operators AND and OR. You can also use these conditional operators: < (smaller than), <= (smaller than or equal), > (larger than), >= (larger or equal), = (equal), and <> (not equal).

Under KiXtart, several special characters can be used to mark special syntactic constructions. For instance, the dollar sign ($) is used to mark a variable, the at sign (@) specifies a macro, and the percent sign (%) indicates an environment variable.

Generating a Script

A brief example can illustrate how a logon script is generated. We are going to verify which group a user belongs to during the logon procedure. Depending on the group, we will assign the file server for the home directory, and we will connect the default printer.

Listing 7-8: KiXtart Script for Assigning a Home Directory and a Default Printer
Start example
; Check group membership and set the $server variable
IF InGroup("marketing")
 $server = "FILESRV1"

IF InGroup("development")
 $server = "FILESRV2"

; Assign drive letter u to home directory
USE U: "\\$server\@userid"
; Set printer parameters
addprinterconnection (\\PRINTSRV\HPLJ22)
setdefaultprinter (\\PRINTSRV\HPLJ22)
End example

For the script to run during user logon, it needs to be assigned to the relevant account properties or to be invoked from a conventional logon script. If the KiXtart script is named Klogin.src, the following line applies:

kix32 klogins.src

KiXtart is not officially supported by Microsoft, despite the fact that it was developed by a Microsoft employee. For this reason, the corresponding mechanisms should not be used on critical systems that depend on fast Microsoft support. However, KiXtart can be a very powerful tool in a terminal server environment if you know how to work with it.