How to Create a Logon Script with KiXtart
What is KiXtart?
When I first chose this presentation topic, I thought that KiXtart was a program.
You know, "Use KiXtart to create a logon script"? I thought that it was going to be a GUI interface with options and it would be really easy to create a script.
I was definitely wrong, KiXtart is actually a scripting LANGUAGE!
History
KiXtart was developed by a Microsoft employee named Rud van Velsen of the Netherlands way back in 1991.
Velsen set out to create a scripting language for Microsoft LAN Manager, for which, he had gotten many requests.
(LAN Manager was a Network Operating System developed specifically for 3COM network cards in the late 80s to early 90s)
He also wanted to create a language that offered more functionality than a simple batch script.
It was a simple project that he worked on in his spare time, it was not funded by Microsoft.
Once the first version was finished, Velsen released it as freeware to European bulletin boards.
It quickly gained popularity with LAN Manager network admins because of its ease of use and the lack of alternatives.
Soon, Windows NT and Windows 95 made their debut, and KiXtart quickly added support.
Over time, it grew to add many more features and support Windows operating systems up through Windows Server 2008 and Windows 7.
How to get it?
Like I just mentioned, KiXtart was originally distributed through bulletin boards.
Later it was available on websites, distribution lists, and even as part of some Microsoft Resource Kits.
Now, you can download it exclusively from its homepage:
KiXtart.org (Direct Link).
Now, many of you are probably thinking, "Wait, download? I thought this was a language and was natively supported by Windows?"
Well, it's actually not natively supported by Windows. IT supports Windows, not the other way around.
KiXtart is quite different than simply creating a batch file and double clicking to run.
It requires an executable file which runs the scripts from a command line. (i.e. "kix32.exe sample.kix") More on this in the next section.
Using KiXtart
Ok, I'll be using my XP machine to demonstrate various scripts.
Lets start off with an easy one to explain the process: A simple "Hello World!" script.
To create the script, go into the folder that contains "KIX32.EXE". Mine is on my desktop in the folder "KiX2010.461".

Now, open up a text editor such as Notepad (I use Notepad++)
Create new file and include this code:
;--------start hello.kix--------
"Hello World!" ?
;-------- end hello.kix--------
Now, as you may notice, there are two types of lines here:
In KiX, the semicolon(";") is a REM mark. (like "#" in Batch Files and "//" in C#)
Also, the question mark(?) at the end acts as a "line return" command just like "/n" in many other languages.
The other line is our print line. All you need to do is type anything between two double quotes and the script with print it to the command line.
Save the file as "hello.kix" in the same folder as "KIX32.EXE".
There are two ways to run the script, I'll show both ways now, but in the next example, we'll only use the second method.
Method #1
The first method is to run the script directly from a command line.
To do this, we open the command prompt (RUN -> "cmd") and navigate to the folder. Again, mine is "C:\Documents and Settings\Matt\Desktop\KiX2010.461".
Now, type "kix32.exe hello.kix" and hit enter. It will return like this:

Method #2
This is the second and most preferred method.
Most actual login scripts using KiXtart use a batch file to call the actual script with the line above.
For this method, create a batch file in the same directory as the "kix32.exe" and "hello.kix" files.
@ECHO OFF
kix32.exe hello.kix
pause
exit
Save as "run.bat"!
Now we can simply open the folder and double click "run.bat" and we get this:

This is much more convenient than having to open a console window each time, plus, it's easier to simply point to the batch file at logon.
Slightly More Advanced Scripts
Ok, what we're going to do now a bit more complicated.
What I want to do is map a network drive to "Z:" on my desktop (MATTX2) then send a message to me saying it was completed (or failed).
The drive I want to map is on my laptop: "\\Mattop\C\test"
WARNING! I WENT A BIT OVERBOARD HERE!
So, I create a new KiX script called "map.kix" and wrote this in it:
;--------start map.kix--------
$share = "\\mattop\c\test"
USE Z: /DELETE
USE Z: "$share" /user:matt /password:***********
IF @ERROR = 0
  SendMessage("Mattx2" , "Connected " + @RESULT + " to $share.") ?
ELSE
  SendMessage("Mattx2" , "Could not connect, error#: @ERROR") ?
ENDIF
:EXIT
;-------- end map.kix--------
In short, "$share" is a variable holding my desired share.
"" first deletes any existing share on "Z:" then maps my share to drive z using my username and password.
If there are no errors, it sends a popup message to me on my desktop (Mattx2) that tells me the result.
If there is an error (@ERROR != 0), it tells me and gives me the error code.
It then ends the IF statement and exits the script!
Now, I wanted to unmap the drive after, so I wrote "unmap.kix" and a batch file menu to consolidate the process:
UNMAP.KIX
;--------start unmap.kix--------
$share = "\\mattop\c\test\"
USE Z: /DELETE
IF @ERROR = 0
 SendMessage("Mattx2" , "Successfully disconnected from $share.") ?
ELSE
  IF @ERROR = 2250
   SendMessage("Mattx2" , "Drive already disconnected!") ?
  ELSE
   SendMessage("Mattx2" , "Failed to disconnect from $share. Error#: @error") ?
  ENDIF
ENDIF
:EXIT
;-------- end unmap.kix--------
RUN.BAT
@ECHO OFF
setLocal EnableDelayedExpansion
:menu
  echo Choose an option:
  echo Type 1 to map drive Z.
  echo Type 2 to unmap drive Z.
  echo Type 3 to exit.
  echo.
  set /p pr=
  echo.
  if %pr% == 1 kix32.exe map.kix
  if %pr% == 2 kix32.exe unmap.kix
  if %pr% == 3 exit
  if %pr% neq 3 if %pr% neq 2 if %pr% neq 1 goto :menu
Batch file menu:

Choice #1:

Choice #2:

To show what the mapped drive looks like:

Final Thoughts
Well, that's about it.
Oh, and to run these as logon scripts, use the first batch file and set it to run as a logon script!
For what we're doing in this class, I believe that KiXtart is WAY overkill.
Looking around their website and others, it's apparent that it's power as a scripting language is incredible.
Some links that helped me were:
http://www.scriptlogic.com/Kixtart/htmlhelp/Commands/use.htm (USE command)
http://www.scriptlogic.com/Kixtart/htmlhelp/Reference/!keyword-index.asp (Most KiXtart keywords and functions)
http://viewpointproperties.com/techtips/loginScriptExample.html (Sample login script)
http://www.hiteksoftware.com/mize/Knowledge/articles/049.htm (Windows System Error Codes)
http://www.microsoft.com/windowsxp/using/security/learnmore/stopspam.mspx (If you need to enable system messages)