Migrating Print Server - TechNet Articles - United States (English) - TechNet Wiki

In his article about the batch creation of printers I described how you can without much time and moral cost, quickly create a similar set of printers on the new server.

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.

Migrating Print Server

In his article about the batch creation of printers I described how you can without much time and moral cost, quickly create a similar set of printers on the new server.

According to the problem we have in the old and the new print server. r />
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:

  1. Rename the server.
  2. reconnect all printers for clients on a new printer.

The first option, the default is "unsportsmanlike" and it will be the second option.

Step 1

Create a file called PRINTERS.txt , reading:

\\prnsrv\HP-C6200
\\prnsrv\KS-Prn1
\\prnsrv\PD-Prn2-Color


Each line of the file contains the full path to the "old" printers.

Step 2

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

End If

Loop

oFile.Close

else

WScript.Echo "File – " & sFile & " not found."

End If

 

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


Step 3

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.


Source Link