Hey Guys,

A while ago I posted up this little number looking to add printers based on OUs.
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Main=27580&Number=205533#Post205533

Well I'm finally getting around to it and running into a bit of a snag and wondering if I should actually take another direction in total.

This code is terrible, it's just in testing phases and I'll wind up cleaning it up.

 Code:
;If Instr($OU,"Terminal Servers") AND InStr($OU,"Headquarters")
  ;Do Stuff...
;Endif

;****************************************************************
; Declare Variables Here:

call "@ldrive\udf\alludf.kix"

If @ONWOW64 = 1
	$printserver = "skm-print3"
else
	$printserver = "skm-print1"
EndIf

$printserver1 = "skm-print1"
$printserver2 = "skm-print2"
$printserver3 = "skm-print3"


;******************************************************************

; Some Quick Formalities:
If Not @LOGONMODE
	Break on
EndIf


? @FULLNAME + ": Please wait while your printers are being added...."

$OU = GetObject("LDAP://"+CreateObject("ADSystemInfo").ComputerName).Parent

;Can uncomment this for testing OU Settings:
? "$OU"
;Can uncomment this for testing print server settings:
? "$printserver"

select

	case instr ($OU,"Business Office") and instr ($OU,"Computers") and instr ($OU,"Insert Facility Here")
		? "Business Office"
	case instr ($OU,"Education") and instr ($OU,"Computers") and instr ($OU,"Insert Facility Here")
		? "Education"
	case instr ($OU,"ER") and instr ($OU,"Computers") and instr ($OU,"Insert Facility Here")
		? "ER"
	case instr ($OU,"Training Room") and instr ($OU,"Computers") and instr ($OU,"Insert Facility Here")
		? "Training Room"
	case instr ($OU,"Specility Clinic") and instr ($OU,"Computers") and instr ($OU,"Insert Facility Here")
		? "Spec Clinic"
	case instr ($OU,"Insert Facility Here IT") and instr ($OU,"Computers")
		? "IT Printers"
		;printer_map("$printserver",'IT-PR2')
		;printer_map("$printserver",'IT-PR3')
		
endselect

sleep 10

;Map Printers
function printer_map($server,$printer)
	AddPrinterConnection("\\$server\$printer")
		error_check(@ERROR,@SERROR,"couldnt add $printer from $server")
endfunction
;Map Default Printers
function default_printer_map($server,$printer)
	SetDefaultPrinter("\\$server\$printer")
		error_check(@ERROR,@SERROR,"couldnt make $printer default from $server")
endfunction
;Error Checking For Script
function error_check($errnum,$error,$message)
		If @ERROR<>0
		$txtlog = "\\skm-file01\logonlogs$\pcprinters.txt"
		$sFile = "\\skm-file01\logonlogs$\"
		open(1,$sFile)
		$rc = WriteLog($txtlog,@WKSTA+" "+Join(Split(@IPADDRESS0),"")+" "+ @USERID + " "+ @DATE + " " + @TIME + " Error# $errnum $error $message" + Chr(13) + Chr(10))
	EndIf
endfunction


I'm sure it's just syntax, but when I run the script my desktop belongs to the Facility IT Computers (which is the last case in this statement). Instead it's getting caught by the ER Group. Others are getting caught as well.

Any thought on the syntax from the original post.

Also does anybody have any good (and instructions for id10ts) ini file for printer examples? I'm wondering if that is a better way to go long term.

Thanks for the help and thoughts