#150840 - 2005-11-01 03:49 PM
!IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
Hello People
I have a big Problem with the Printmigration
I have 150 Printers and now i will change my Printserver. The old Printer's call homeprinter1, homeprinter2...The new nameconversation is now printer1, printer2.... So i have make a Script: ------------------------------------------------------- If DelPrinterConnection ("\\server1\homeprinter1") = 0 AddPrinterConnection ("\\server4\printer1") EndIf . . . . . -------------------------------------------------------
That's function good, but the the loginscript using a long time to running because they are so much printers...
Have you got anothter solution??? It's very important for me.
best regards wk2x
PS: Thank you for your help
|
Top
|
|
|
|
#150842 - 2005-11-01 05:27 PM
Re: !IMPORTANT! Printmigration
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Here is a function that I use to remap printers...
Code:
Function fnRemapPrinter($sOldPath,$sNewPath) Dim $i,$nul,$sPorts,$sDefault,$sPrinters[25] If @INWIN=1 $sPorts="HKCU\Printers\Connections\" $sDefault=Split(ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0] Do $sPrinters[$i]=EnumKey($sPorts,$i) $i=$i+1 If Ubound($sPrinters)=$i Redim Preserve $sPrinters[Ubound($sPrinters)+25] EndIf Until @ERROR Redim Preserve $sPrinters[$i-1] For $i = 0 to Ubound($sPrinters) If Join(Split($sPrinters[$i],","),"\") = $sOldPath $nul = DelPrinterConnection($sOldPath) $nul = AddPrinterConnection($sNewPath) If $sDefault = $sOldPath $nul = SetDefaultPrinter($sNewPath) EndIf EndIf Next EndIf Exit @ERROR EndFunction
|
Top
|
|
|
|
#150843 - 2005-11-01 05:44 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
yes, i can. HKEY_CURRENT_USER -> Connections > ,,server1,homeprinter1
and in this Section are Server with the Value \\server1
|
Top
|
|
|
|
#150844 - 2005-11-01 05:46 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
Thank you for your help, but when i testing your script.... they Printers aren't make anything
|
Top
|
|
|
|
#150846 - 2005-11-01 06:54 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
ohhh, no i think you understand me false. I have a 2 Printservers an old and a new. The Old Printers are all again installed on the new Server. But the Client's use still the old Server. So i need a script for the clients that running fast and add the printer they are installed on the clients again. Naturally from the new Server with the new naming convention. Do you know what i mean?
|
Top
|
|
|
|
#150847 - 2005-11-01 07:00 PM
Re: !IMPORTANT! Printmigration
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
The PriMapState should be all that you need..
PriMapState() - Checks for existent printerconnection
We have used it many times with printers being moved around to other servers and it works great!
Kent
|
Top
|
|
|
|
#150848 - 2005-11-01 07:12 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
hmmm..interesting... have you got an example from a move script...sorry, i don't understanding this script...
|
Top
|
|
|
|
#150852 - 2005-11-01 08:41 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
now, i'am confused..
-----------------------------------------------
$sOldPath = "\\server1" $sNewPath = "\\server4"
Function fnRemapPrinter($sOldPath,$sNewPath) Dim $i,$nul,$sPorts,$sDefault,$sPrinters[25] If @INWIN=1 $sPorts="HKCU\Printers\Connections\" $sDefault=Split(ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0] Do $sPrinters[$i]=EnumKey($sPorts,$i) $i=$i+1 If Ubound($sPrinters)=$i Redim Preserve $sPrinters[Ubound($sPrinters)+25] EndIf Until @ERROR Redim Preserve $sPrinters[$i-1] For $i = 0 to Ubound($sPrinters) If Join(Split($sPrinters[$i],","),"\") = $sOldPath $nul = DelPrinterConnection($sOldPath) $nul = AddPrinterConnection($sNewPath) If $sDefault = $sOldPath $nul = SetDefaultPrinter($sNewPath) EndIf EndIf Next EndIf Exit @ERROR EndFunction
---------------------------------------
What i make false? thank you for your help
|
Top
|
|
|
|
#150854 - 2005-11-01 09:39 PM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
How i use this Script, when the old servername is server1 and the new server4 and the printer change from homeprinter1,homeprinter2... to printer1, printer2...?
Thank you for your HELP
|
Top
|
|
|
|
#150856 - 2005-11-02 10:25 AM
Re: !IMPORTANT! Printmigration
|
wk2x
Fresh Scripter
Registered: 2005-11-01
Posts: 10
|
-------------------------------
Function fnRemapPrinter("server1","server4") Dim $i,$nul,$sPorts,$sDefault,$sPrinters[25] If @INWIN=1 $sPorts="HKCU\Printers\Connections\" $sDefault=Split(ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0] Do $sPrinters[$i]=EnumKey($sPorts,$i) $i=$i+1 If Ubound($sPrinters)=$i Redim Preserve $sPrinters[Ubound($sPrinters)+25] EndIf Until @ERROR Redim Preserve $sPrinters[$i-1] For $i = 0 to Ubound($sPrinters) $share=Split($sPrinters[$i],",") $share=$share[ubound($share)] $nul = DelPrinterConnection("\\server1\"+$share) $nul = AddPrinterConnection("\\server4\"+$share) If $sDefault = $sOldPath $nul = SetDefaultPrinter($sNewPath) EndIf EndIf Next EndIf Exit @ERROR EndFunction
-------------------------------------
what i make false????....it doesn't work
|
Top
|
|
|
|
#150857 - 2005-11-02 02:38 PM
Re: !IMPORTANT! Printmigration
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
The function I posted above works at the printer level so an example of using it would look like...
Code:
fnRemapPrinter("\\oldserver\oldprinter","\\newserver\newprinter")
Here is one that remaps printers that just move to a different server, but retain the same printer share name...
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
It will remap any printer the user has installed that is pointed to the old print server and remap it to the new print server. It will also work with 9x client, but they require a reboot whereas NT-based systems do not require a reboot.
|
Top
|
|
|
|
#150858 - 2005-11-02 02:41 PM
Re: !IMPORTANT! Printmigration
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Also, from the sample you posted it would appear that you do not understand how to use User Defined Functions (UDFs). Please read the FAQ on How to use UDFs.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|