;================================================================================================
; Checks if printer is installed, and installs the correct printer based on area
;================================================================================================
Function PrintInstall($PrintFile) ;This part installs the printer
$handle = Freefilehandle()
IF $handle > 0
IF Open($handle, $ServerName + "\setup printers\" + $Printfile) = 0
? $Servername
$printsetup = Readline($handle)
WHILE @ERROR = 0
$ReturnCode = KeyExist("Hkey_Current_User\printers\Connections\,," + $PrintServer + "," + $printsetup)
IF $ReturnCode = 1
? $printsetup + " Printer is already installed"
ELSE
? "We need to install this printer " + $printsetup
AddPrinterConnection($ServerName + "\" + $printsetup) ;I presume that I need to put the loop after this line and to loop back to IF $ReturnCode = 1
ENDIF
$printsetup = ReadLine($handle) ;This part checks if kixtart can open the file and read the contents
LOOP
IF Close($handle)
Beep
? "Error closing file!"
ENDIF
ELSE
? "Unable to open" + $ServerName + "\setup printers\" + $PrintFile
ENDIF
ELSE
? "Unable to obtain a free system handle."
ENDIF
EndFunction