KiXtart


KiXtart is an easy-to-use scripting language available for download from http://www.KiXtart.org. Some of the advanced features of KiXtart are built-in debugging, the ability to modify the registry, COM automation, and the ability to shut down or reboot systems. Although primarily used for logon scripting, KiXtart can be used as a standalone scripting solution to automate everyday tasks .

Commands

Like Shell Scripting commands, KiXtart commands are built-in routines used to perform an action. KiXtart contains many commands similar to Shell Scripting commands (COPY, MOVE DEL, CD), but adds many advanced commands allowing you to create powerful scripts. Many KiXtart commands return codes that indicate the success or failure of the completed operation. You can use a KiXtart variable to store and examine the code returned from the executed command:

 $RETURNCODE = ClearEventLog("Application") 

Variables

Variables are used extensively in KiXtart to store values or return codes. KiXtart variable names consist of a $ sign followed by text, and should not be the same as any of the built-in KiXtart component names . Optionally, declaring a variable and assigning a value is identical to doing so in a language like VBScript:

 DIM $MYVARIABLE $MYVARIABLE = "SOME VALUE" 

Functions

Imagine if you had to perform a series of twenty steps on more than 1,000 files. What a pain it would be to rewrite those steps so many times! A function is a procedure used to perform a series of actions and return data. A typical use of a function is to perform calculations, create objects, or return error codes. A KiXtart function is structured as follows :

 Function FunctionName (  arguments  )   Code EndFunction 

Here, FunctionName is the name given to the function; arguments are the parameters passed to the function (separated by commas); and Code is the script action(s) to perform. To return a value outside of the function, you should name a variable from within your function with the same name as your function and set a value to it.

Macros

KiXtart macros provides various system and user information by accessing Windows Application Programming Interfaces (APIs). (I'll be discussing Windows APIs a little later in this chapter when we look at the Windows Script Host tool). KiXtart has over 50 built-in macros to easily return various system and network information. All macros are prefixed with an @ symbol. Some of the more commonly used macros are listed in Table 1.1.

Table 1.1: Commonly used KiXtart macros.

Macro

Definition

@ ERROR

Return code of the last command or function.

@ LDRIVE

Drive that maps to \\ LogonServer \NETLOGON.

@ LSERVER

Validating Server Name.

@ SCRIPTDIR

Directory of the currently running script.

@ SERROR

Description of the last error.

@ USERID

Username of the current user.

@WKSTA

Local computer name.

KiXtart

Scripting Example.

Let's revisit our simple example of displaying the name of your local computer to see how KiXtart compares with shell scripting. If you do not currently have a copy of KiXtart on your computer, you'll need to download a copy from the Web using the instructions that I have provided.

Displaying the Computer Name

To display the name of the local computer using KiXtart, proceed as follows:

  1. Create a new directory to store all files included in this example.

  2. Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.

  3. Use your favorite text editor to create a new script file. The following instruction should be placed in the file:

     ? @WKSTA sleep 5 

    This instruction might look a little unusual but it simply uses the "?" command to display the contents of the @WKSTA macro.

    To finish your script file, simply save it using a filename that you will remember.

  4. Now you are ready to run your script. Select StartRun and enter "kix32 scriptfile. "

Here, scriptfile should be the full path and file name where your file is stored (Step 3). The SLEEP command is used to pause script execution for 5 seconds, allowing us to view the results.

Limitations of KiXtart

Since KiXtart is not a built-in Windows feature, you must either copy it to every system or make it available by sharing it across a network. This isn't difficult but it is an administrative task you'll need to take care of. A KiXtart script also tends to run slower for remote access or linked site users than a Windows Script Host script. Finally, KiXtart is not currently supported by Microsoft.

When to Use KiXtart

KiXtart is a great alternative to shell scripting due to its built-in debugging, network, file, and registry functions. It's a perfect solution to simplify complex shell scripting tasks and remains a popular choice for logon scripting. With more and more features being added to every release, KiXtart's capabilities are slowly reaching those of Windows Script Host.




Windows Admin Scripting Little Black Book
Windows Admin Scripting Little Black Book (Little Black Books (Paraglyph Press))
ISBN: 1933097108
EAN: 2147483647
Year: 2004
Pages: 89

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net