Okay, I've modified the script so that it will add printers based upon the INI file, how do I make it delete printers from computers when they do not exist in the INI file?
code:
;********** Prevent logon script on server *********
call @ScriptDir+'\osid.udf'
$os=osid()
if $os[2]<>'Workstation'
exit 0
endif
;********** Beginning of printer info gathering script *********
;Default Printer Configuration
;This is to capture the Default Printer and get all network defined printers as well
$loc='HKEY_CURRENT_USER\Network\LPT1'
$reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=split(READVALUE($reg+'\Windows','Device'),',')[0]
$sysdrv=SUBSTR('%WINDIR%',1,2)
dim $priReg, $x, $i, $rc, $ps
;---- Set Printsetup.ini file location ----
$ps=('\\mrh-01\prtlog$')
$ps=($ps+'\@wksta')
IF 0=EXIST($ps)
MD $ps
ENDIF
$ps=$ps+'\Printsetup.ini'
$i=0
DO
IF '\\'=LEFT($x,2)
$priReg=$priReg+$x
ENDIF
$x=ENUMVALUE($dev,$i)
$i=$i+1
UNTIL @error
SELECT
CASE EXIST($ps) ;PRINTERS FROM SAVED INFO
FOR EACH $key IN split(READPROFILESTRING($ps,'Printers',''),chr(10))
$nul=addprinterconnection(READPROFILESTRING($ps,'Printers',$key))
NEXT
$nprt=READPROFILESTRING($ps,'Printers','Default')
$rc=SETDEFAULTPRINTER($nprt)
USE LPT1: $nprt /persistent
CASE NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
USE LPT1: /delete /persistent
ENDSELECT