;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