According to the problem we have in the old and the new print server. In my case this is an old Windows 2003 and the new Windows 2008 R2. The "new" print server, we installed a set of similar "old" printer server. Today I want to talk about what needs to be done on the client in order to connect these printers.
Traditionally, few options can be:
The first option, the default is "unsportsmanlike" and it will be the second option. Step 1
Create a file called PRINTERS.txt , reading:
Each line of the file contains the full path to the "old" printers.
Create a .vbs file with the contents below.
on error resume next
Set objNetwork = WScript.CreateObject("WScript.Network")
Set colPrinters = objNetwork.EnumPrinterConnections
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject( "WScript.Shell" )
‘ specify the path to the file you created earlier
sFile = "printers.txt"
oldServer = "OLD_SERVER"
newServer = "NEW_SERVER"
If objFSO.FileExists(sFile) Then
‘ read default printer settings
strKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
strCurPrinter = Trim( Split( wshShell.RegRead( strKey ), "," )(0) )
‘WScript.Echo "Current Default printer – " & strCurPrinter
‘We form the name of the new default printer
strNewPrinter = Replace (strCurPrinter, oldServer , newServer)
‘ We make replacing your printer on new
If strCurPrinter <> strNewPrinter Then
objNetwork.AddWindowsPrinterConnection strNewPrinter
‘WScript.Echo "New Default printer – " & strNewPrinter
objNetwork.SetDefaultPrinter strNewPrinter
objNetwork.RemovePrinterConnection strCurPrinter
End if
‘ Read from a file printer list
Set oFile = objFSO.OpenTextFile(sFile, 1)
‘ in a loop we read a line from a file
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If Trim(sText) <> "" Then
‘WScript.Echo "value from file – " & sText
‘ We are comparing each line found in printers
For i = 0 to colPrinters.Count -1 Step 2
‘WScript.Echo "Value from Windows – " & colPrinters.Item (i+1)
‘ If the comparison is successful the form variable and call the subroutine newPrinter replacement printer
If Ucase(colPrinters.Item (i+1)) = Ucase(sText) Then
oldPrinter = sText
newPrinter = Replace (oldPrinter, oldServer, newServer)
SwapPrinter
End If
next
Loop
oFile.Close
else
WScript.Echo "File – " & sFile & " not found."
WScript.Quit
‘ подпрограмма замены принтера
Sub SwapPrinter
Set WshNetwork = CreateObject("WScript.Network")
WScript.Echo "Create new printer – " & newPrinter
WshNetwork.AddWindowsPrinterConnection newPrinter
WScript.Echo "Delete old printer – " & oldPrinter
WshNetwork.RemovePrinterConnection oldPrinter
End Sub
The resulting script is run under the user once by any method, for example, he can put it in startup and after some time off.
The result of mining will be replacing all the printers on the old server to new one.
Richard Mueller edited Revision 2. Comment: Removed (en-US) from title, added tag
Balaji M Kundalam edited Revision 3. Comment: Typography - minor edit
Maheshkumar S Tiwari edited Revision 5. Comment: Added Tag
Patris_70 edited Original. Comment: completed