I'm new to scripting, so any help would be greatly appreciated. We are using roaming profiles in a W2K environment. Kixtart doesn't seem to recognize what groups the PCs are in (only users), so we've set an System Environment Variable (DefaultPrinter) on each PC which Kixtart can use to identify that computer's default printer. Below are the scripts I'm testing. My problem is the SetDefault script stops running on the line If @ERROR = 0. What am I doing wrong? Is there any way to reset that error value to zero?
Thank you all for your help.

**************************
ADDPRINTER.KIX
**************************
addprinterconnection("\\PrintServer\Admin")
addprinterconnection("\\PrintServer\Control-A")
addprinterconnection("\\PrintServer\Control-N")
addprinterconnection("\\PrintServer\Desk")
addprinterconnection("\\PrintServer\Library")
addprinterconnection("\\PrintServer\News Coordinator")
addprinterconnection("\\PrintServer\Operations")
addprinterconnection("\\PrintServer\Pod")
addprinterconnection("\\PrintServer\Specials")
addprinterconnection("\\PrintServer\Sports")
addprinterconnection("\\PrintServer\Studio-N")
addprinterconnection("\\PrintServer\Traffic")
addprinterconnection("\\PrintServer\HR")
? "A"
CALL "@LSERVER\netlogon\SetDefault.kix"
? "B"
exit
? "C"
**************************
SETDEFAULT.KIX
**************************
$Temp = SubStr($PrinterName,3,999)
? "1"
$PrinterServer = SubStr($Temp,1,InStr($TEMP,"\")-1)
? "2"
$PrinterShare = SubStr($Temp,InStr($TEMP,"\")+1,999)
? "3"
$RegKey = ",,"+$PrinterServer+","+$PrinterShare
? "4"

$Index = 0
? "5"
WHILE @ERROR = 0
? "6"
$ValueName = ENUMKEY("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$Index )
? "7"
If @ERROR = 0
? "8"
IF INSTR($Valuename,$RegKey) <> 0
? "9"
$PrinterType = SubStr($ValueName,InStr($ValueName," - "),999)
? "10"
$DeviceName = "\\"+$PrinterServer+"\"+$PrinterShare+$PrinterType+",winspool,Ne0"+$Index+":"
? "11"
SETDEFAULTPRINTER ("\\PRINTSERVER\"$PrinterType)

? "12"
ENDIF
ENDIF
$Index = $Index + 1
LOOP

:EndProgram