$Printer = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
$Server = Split($Printer,"\")
$sPrinterShare = Split($Server[3],",")
$PrinterName = $sPrinterShare[0]
$OldServerName = $Server[2]
If $Server[2] = "NewServer1" Or
$Server[2] = "NewServer2"
Goto additional
Else
Select
Case Right($sPrinterShare[0],1)=1
$NewServerName="NewServer1"
Case Right($sPrinterShare[0],1)=3
$NewServerName="NewServer1"
Case Right($sPrinterShare[0],1)=5
$NewServerName="NewServer1"
Case Right($sPrinterShare[0],1)=7
$NewServerName="NewServer1"
Case Right($sPrinterShare[0],1)=9
$NewServerName="NewServer1"
Case 1
$NewServerName="NewServer2"
EndSelect
EndIf
$OldValue = "\\"+$OldServerName+"\"+$PrinterName
$NewValue = "\\"+$NewServerName+"\"+$PrinterName
$rc=DelPrinterConnection("$OldValue")=0
$rc=AddPrinterConnection("$NewValue")=0
:additional
Dim $iIndex, $sPrinterkey[]
$iIndex = 0
While @ERROR=0
ReDim Preserve $sPrinterkey[$iIndex]
$sPrinters="HKCU\Printers\Connections"
$sPrinterKey[$iIndex] = EnumKey($sPrinters,$iIndex)
$iIndex=$iIndex+1
Loop
For Each $ in $sPrinterkey
$OldServerName=Split($,",")[2]
If $<>""
If Split($,",")[2] = "NewServer1" Or
Split($,",")[2] = "NewServer2"
Exit
Else
Select
Case Right(Split($,",")[3],1)=1
$NewServerName="NewServer1"
Case Right(Split($,",")[3],1)=3
$NewServerName="NewServer1"
Case Right(Split($,",")[3],1)=5
$NewServerName="NewServer1"
Case Right(Split($,",")[3],1)=7
$NewServerName="NewServer1"
Case Right(Split($,",")[3],1)=9
$NewServerName="NewServer1"
Case 1
$NewServerName="NewServer2"
EndSelect
EndIf
$OldValue = "\\"+$OldServerName+"\"+Split($,",")[3]
$NewValue = "\\"+$NewServerName+"\"+Split($,",")[3]
$rc=DelPrinterConnection("$OldValue")=0
$rc=AddPrinterConnection("$NewValue")=0
EndIf
Next