Right Guys!
This is the code I am using, kindly supplyed to me by Richard (Thanks) I have done the initial testing and is doing exacly what I need, just I don't know how to add that (getdefault)+(delprintconnection) to it !
Obviously it is calling printemap.ini files for the printers....
Code:
Break ON
$bDEBUG=1
CLS
$sPrinterIni= @scriptdir + "\PrinterMap.ini"
$iIndex=0
$iDefaultDone=0
$sGroup=EnumGroup($iIndex)
While $sGroup AND Not @ERROR
; Drop domain
If InStr($sGroup,"\") $sGroup=SubStr($sGroup,InStr($sGroup,"\")+1) EndIf
; Check if there is a printer map for this group
If $bDEBUG Color w+/b "DEBUG: Looking for section [LOCATION "+$sGroup+"]" Color w/n ? EndIf
For Each $sPrinter in Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,""),Chr(10))
If $sPrinter
$asPrinterPair=Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,$sPrinter),"|")
"Mapping primary printer path "+$asPrinterPair[0]
If AddPrinterConnection($asPrinterPair[0])
" " Color r+/n "*FAILED*" Color w/n @CRLF
"Mapping alternative printer path "+$asPrinterPair[1]
If AddPrinterConnection($asPrinterPair[1])
" " Color r+/n "*ALSO FAILED*" Color w/n @CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Else
" " Color g+/n "OK" Color w/n @CRLF
If Not $iDefaultDone
"Setting printer as default"
If SetDefaultPrinter($asPrinterPair[1])
" " Color r+/n "*FAILED*" Color w/n @CRLF
"ERROR: Could not set printer as default."+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Else
" " Color g+/n "OK" Color w/n @CRLF
$iDefaultDone=1
EndIf
EndIf
EndIf
Else
" " Color g+/n "OK" Color w/n @CRLF
"Setting printer as default"
If Not $iDefaultDone
If SetDefaultPrinter($asPrinterPair[0])
" " Color r+/n "*FAILED*" Color w/n @CRLF
"ERROR: Could not set printer as default."+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Else
" " Color g+/n "OK" Color w/n @CRLF
$iDefaultDone=1
EndIf
EndIf
EndIf
EndIf
Next
$iIndex=$iIndex+1
$sGroup=EnumGroup($iIndex)
Loop

Exit 0