;Script Options
;Break ON
CLS
;;;;;;;;;;;;;;;;;;;;;;;;;Funktionen;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Funktion "Standarddrucker"
Function GetDefaultPrinter()
$GetDefaultPrinter = Join(Split(ReadValue("HKEY_USERS\"+@SID+"\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'')
EndFunction
;Funktion "Zeichersetzung"
Function Replace($SourceString,$ChrToReplace,$ReplacementChr)
$Array = Split($SourceString,$ChrToReplace,-1)
For Each $Element In $Array
$Replace = $Replace + $Element + $ReplacementChr
Next
$Replace=substr($Replace,1,len($Replace)-1)
ENDFUNCTION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Break on
; Überprüfung, ob eine Druckermapping für die Gruppe da ist.
$bDEBUG=0
$sPrinterIni= @SCRIPTDIR + "\PrinterMap.ini"
If ReadProfileString($sPrinterIni,"","")
If $bDEBUG
"DEBUG: Die folgenden Sektionen erscheinen in der INI.-Datei:" ?
"-----------------------------------------------------" ?
ReadProfileString($sPrinterIni,"","")
"-----------------------------------------------------" ?
EndIf
Else
If Exist($sPrinterIni)
"ERROR: INI-Datei '"+$sPrinterIni+"' ist leer oder ungültig!" ?
Else
"ERROR: INI-Datei '"+$sPrinterIni+"' existiert nicht!" ?
EndIf
Exit 1
EndIf
; Zwischenspeicherns des Standarddruckers
DIM $DefaultPrinter
$DefaultPrinter=GetDefaultPrinter()
; AUfruf der Funktion ""Drucker entfernen"
"Entferne bestehende Druckerverbindungen ..." @CRLF
DIM $IdxNum
$IdxNum = 0
:Loop1
$PrnPath = EnumKey("HKEY_CURRENT_USER\Printers\connections\", $IdxNum)
If @ERROR = 0
$PrnPath = Replace($PrnPath,",","\")
$rs = DelPrinterConnection ($PrnPath)
? $IdxNum
? $PrnPath
$IdxNum = $IdxNum + 1
GoTo Loop1
EndIf
@CRLF "Fertig." @CRLF
$iIndex=0
$iDefaultDone=0
$sGroup=EnumGroup($iIndex)
While $sGroup AND Not @FEHLER
; Wegfallenlassen des Domainteils nlkhhi\
If InStr($sGroup,"\") $sGroup=SubStr($sGroup,InStr($sGroup,"\")+1) EndIf
If $bDEBUG Color w+/b "DEBUG: Looking for section [LOCATION "+$sGroup+"]" Color w/n ? EndIf
; Überprüfung, ob ein Druckermapping für die Gruppe da ist.
For Each $sPrinter in Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,""),Chr(10))
If $sPrinter
$asPrinterPair=Split(ReadProfileString($sPrinterIni,"LOCATION "+$sGroup,$sPrinter),"|")
"Mappe primären Druckerpfad "+$asPrinterPair[0]
If AddPrinterConnection($asPrinterPair[0])
" " Color r+/n "*Fehlgeschlagen*" Color w/n @CRLF
"Mappe alternativen Druckerpfad "+$asPrinterPair[1]
If AddPrinterConnection($asPrinterPair[1])
" " Color r+/n "*Ebenfalls Fehlgeschlagen*" Color w/n @CRLF
"Grund: ["+@ERROR+"] "+@SERROR+@CRLF
Else
" " Color g+/n "OK" Color w/n @CRLF
EndIf
Else
" " Color g+/n "OK" Color w/n @CRLF
EndIf
EndIf
Next
$iIndex=$iIndex+1
$sGroup=EnumGroup($iIndex)
Loop
; Setzen des originären Standarddruckers
IF SETDEFAULTPRINTER ("$DefaultPrinter") = 0
? Color b+/n "Der Standarddrucker lautet= $DefaultPrinter ." @CRLF
ELSE
? "Beim Setzen des Standarddrucker ist ein Fehler aufgetreten."
ENDIF
Exit 0