Moving or Changing the Name of Printer Server: Update the User

Here is a script I used a few months ago it is very useful if you are moving or changing the name of your printer server. The script looks at the current users installed network printers which are retrieved for example as;


If the name of the server matches the variable “from_sv” the printer is removed from the user and a new printer is added using the “to_sv” variable from example if the “to_sv” variable was set to “\\newprintserver;

\\ newprintserver \hrprinter
\\ newprintserver \copier1

The script does not create a queue on the new print server it just removes any reference to the old print server and as long as a queue exists on the new server it adds the printer back on for the user pointing at the new server.

To move all of you printer queue, drivers and ports from one server to another take a look at Microsoft’s free tool Print Migrate

This script works great if called from a logon script! And also works fine on Citrix

Sometimes doing a big bang migration from an old print server to a new one is not the best idea, if you would prefer a more granular approach take a look at this script

Dim from_sv, to_sv, PrinterPath, PrinterName, DefaultPrinterName, DefaultPrinter

Dim DefaultPrinterServer, SetDefault, key

Dim spoint, Loop_Counter

Dim WshNet, WshShell

Dim WS_Printers

DefaultPrinterName = ""

spoint = 0

SetDefault = 0

set WshShell = CreateObject("")

from_sv = "\\printserver1" 'This should be the name of the old server.

to_sv = "\\newprintserver" 'This should be the name of your new server.

'Make sure there are printers installed

On Error Resume Next

key = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"

DefaultPrinter = LCase(WshShell.RegRead (key))

If Err.Number <> 0 Then

DefaultPrinterName = ""


'If the registry read was successful then parse out the printer name so we can

' compare it with each printer later and reset the correct default printer

' if one of them matches this one read from the registry.

spoint = instr(3,DefaultPrinter,"\")+1

DefaultPrinterServer = left(DefaultPrinter,spoint-2)

if DefaultPrinterServer = from_sv then

DefaultPrinterName = mid(DefaultPrinter,spoint,len(DefaultPrinter)-spoint+1)

end if

end if

Set WshNet = CreateObject("WScript.Network")

Set WS_Printers = WshNet.EnumPrinterConnections

For Loop_Counter = 0 To WS_Printers.Count - 1 Step 2

PrinterPath = lcase(WS_Printers(Loop_Counter + 1))

if LEFT(PrinterPath,len(from_sv)) = from_sv then

spoint = instr(3,PrinterPath,"\")+1

PrinterName = mid(PrinterPath,spoint,len(PrinterPath)-spoint+1)

WshNet.RemovePrinterConnection from_sv+"\"+PrinterName

WshNet.AddWindowsPrinterConnection to_sv+"\"+PrinterName

if DefaultPrinterName = PrinterName then

WshNet.SetDefaultPrinter to_sv+"\"+PrinterName

end if

end if


Set WS_Printers = Nothing

Set WshNet = Nothing

Set WshShell = Nothing

13 thoughts on “Moving or Changing the Name of Printer Server: Update the User”

  1. This works great. Only thing I need to figure out is how to inject an option to move users to a printer that did not exist before if the were mapped to a now obsolete printer.

    Users were mapped to \\oldprintserver\hp23bw
    need these users to now mappted to \\newprintserver\hp23color

  2. Hello

    I want use this script, but is it possible that when the script is finished with runnig to send a msgbox ” Migration done”. And the 2nd request, to have a log file with the name of hostname and saved on a shardrive.

  3. Hi

    I want use this script but i need a msg box at the end of the script the migration is done. Is it possible to create a log file with the hostname as file name and save it on a sharedrive with content removed printer and installed printer.

  4. I was looking for a simple script to update Win7 clients with a new network printer server name.
    Your script works with Win7 and does the trick, very well done and thanks for sharing!

  5. I ran this script on the client computer and it worked but it created a redirect on both servers of the printers that were reinstalled. When I remove a printer from the client the redirect goes away on the server but if I install a printer on the client, the redirect comes back. Any ideas? Thanks


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.