Hi all!

Found a script made by Chris S.
(http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=150381&an=0&page=2#150381)
the thing is..
we are moving from five diffrent servers,
from to
ex: \\a1-dc1\a1pr0001 > \\a1-dc2\a1pr0001
\\b1-dc1\b1pr0001 > \\b1-dc2\b1pr0001
etc etc.
Therefore I need to use something... and I have no idea...
(Our real kix-guru quit, so... erhm, yeah, I'm here as a temp)

I hope you can help me, and that I don't disturb ya to much!

The original code:
Code:

fnRemapPrinters("oldserver","newserver")

Function fnRemapPrinters($sOldServer,$sNewServer)
Dim $lIndex,$sPorts,$sServer,$sPrinter,$sPort,$sSplit,$lS,$sShare,$NUL,$Err,$sDevice,$sDefault,$sPrinterPorts
Dim $sPrinters[100]
$fnRemapPrinters=0
$lIndex=0
If @INWIN=1
$sPorts="HKCU\Printers\Connections\"
$sDefault=Split(ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]
Do
$sPrinters[$lIndex]=EnumKey($sPorts,$lIndex)
$lIndex=$lIndex+1
If Ubound($sPrinters)=$lIndex Redim Preserve $sPrinters[Ubound($sPrinters)+100] EndIf
Until @ERROR
Redim Preserve $sPrinters[$lIndex-1]
For $lIndex = 0 to Ubound($sPrinters)
$sServer=ReadValue($sPorts+$sPrinters[$lIndex],"Server")
If SUBSTR($sServer,3,LEN($sServer))=$sOldServer
$sPrinter=Split($sPrinters[$lIndex],",")[3]
$NUL=AddPrinterConnection("\\"+$sNewServer+"\"+$sPrinter)
If @ERROR
$Err=@ERROR
Else
If $sDefault="\\"+$sOldServer+"\"+$sPrinter
$NUL=SetDefaultPrinter("\\"+$sNewServer+"\"+$sPrinter)
EndIf
$NUL=DelPrinterConnection("\\"+$sOldServer+"\"+$sPrinter)
If @ERROR $Err=@ERROR EndIf
$fnRemapPrinters=$fnRemapPrinters+1
EndIf
EndIf
Next
Else
$sPorts="HKLM\System\CurrentControlSet\control\Print\Printers\"
Do
$sPrinters=EnumKey($sPorts,$lIndex)
If $sPrinters
$sPort=ReadValue($sPorts+$sPrinters,"Port")
$sSplit=Split($sPort,"\")
If $sSplit[2]=$sOldServer
$lS=Len($sPort)-Len($sOldServer)-2
$sShare=Right($sPort,$lS)
$NUL=WriteValue($sPorts+$sPrinters,"Port","\\"+$sNewserver+$sShare,"REG_SZ")
If @ERROR $Err=@ERROR EndIf
$sDevice=ReadProfileString ("Win.ini", "Windows", "Device")
$sDevice=Split($sDevice,",")
If $sDevice[2]=$sPort
$NUL=WriteProfileString ("Win.ini", "Windows", "Device",
$sDevice[0]+","+$sDevice[1]+","+"\\"+$sNewserver+$sShare)
If @ERROR $Err=@ERROR EndIf
EndIf
$NUL=WriteProfileString ("Win.ini", "Ports", $sPort)
$NUL=WriteProfileString ("Win.ini", "Ports", "\\"+$sNewserver+$sShare, " ")
If @ERROR $Err=@ERROR EndIf
$sPrinterPorts=ReadProfileString ("Win.ini", "PrinterPorts", $sPrinters)
$sPrinterPorts=Split($sPrinterPorts,",")
$NUL=WriteProfileString ("Win.ini", "PrinterPorts", $sPrinters,
$sPrinterPorts[0]+","+"\\"+$sNewserver+$sShare+","+$sPrinterPorts[2]+","+$sPrinterPorts[3])
If @ERROR $Err=@ERROR EndIf
$sDevices=ReadProfileString ("Win.ini", "Devices", $sPrinters)
$sDevices=Split($sDevices,",")
$NUL=WriteProfileString ("Win.ini", "Devices", $sPrinters, $sDevices[0]+","+"\\"+$sNewserver+$sShare)
If @ERROR $Err=@ERROR EndIf
If Not $Err $fnRemapPrinters=$fnRemapPrinters+1 EndIf
EndIf
EndIf
$lIndex=$lIndex+1
Until $sPrinters=""
EndIf
If Not $Err $Err=0 EndIf
Exit $Err
EndFunction




/greets


Björn

[edit]
jooel fixed the code tags.


Edited by Jooel (2005-12-07 03:00 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!