Printer Migration for Clients and Windows 2003 Server

printer-migration

printer-migration

Migrating Printers from One server to the other can be a harmless process and here’s how! First download “Windows Print Migrator 3.1” usually found here if not google it Open the printer migrator on your Old server ( The one you wish to transfer the printers from ) and Select the Action Menu then Backup This will backup all your printers drivers , shares and names etc to a cab file Open the printer migrator on your new server , and Action Menu then Restore. This now replicates the printer setup you had on your old server. All that needs to happen now is the clients need to readd the printers using the new server. This can be automated with this script saved as a .vbs and entered under a group policy for the OU Click on the more to see the code!  

'--------------------8<----------------------
' ChgPrtServer.vbs
' http://www.pcreview.co.uk/forums/thread-431919.php
' http://www.codecomments.com/message323676.html
' created by Helge Wunderlich and Torgeir Bakken

' put in the server names here (keep the quotes!)
MovePrinters "oldservername", "newservername"
 
 
' *********************************************
' Move printers to new server
' *********************************************
Sub MovePrinters(OldServer, NewServer)
' Loops through all network printers and moves all printers
' on "OldServer" to the same printername on "NewServer".
dim WshNetwork, oPrinters, i, PrinterPath, DefaultPrinter, PrinterList
 
' Check that WSH version is new enough:
If CDbl(Replace(wscript.version,".",",")) < CDbl(5.6) Then
MsgBox "Automatic printer migration is not available for" & _
" this computer." & vbCrLf & _
"Please migrate printers manually." & vbCrLf & _
"The new printer server name is """ & NewServer & """", _
vbOKOnly + vbCritical, "Windows Scripting Host is too old"
wscript.quit 1
End If
 
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set PrinterList = CreateObject("Scripting.Dictionary")
 
' Get the default printer before we start deleting:
DefaultPrinter = GetDefaultPrinter
 
' Get a list of printers to work with:
' (We cannot modify the collection while looping through it)
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 1 to oPrinters.Count Step 2
PrinterList.Add oPrinters.Item(i), "x"
Next ' i

' Loop through the printer list and migrate mathching ones:
For Each PrinterPath In PrinterList.Keys
 
If StrComp(ServerName(PrinterPath), OldServer, 1) = 0 Then
WshNetwork.RemovePrinterConnection PrinterPath, True, True
On Error Resume next
WshNetwork.AddWindowsPrinterConnection "\\" & NewServer & "\" & _
ShareName(PrinterPath)
'If Err.Number = -2147023095 Then
' MsgBox "The printer """ & ShareName(PrinterPath) & _
' """ does not exist on server """ & NewServer & """." & vbCrLf & _
' "The printer has been removed.", vbOKonly + vbExclamation, _
' "Missing printer"
'End If
On Error goto 0
End If
Next
 
'Set the default printer:
If ServerName(DefaultPrinter) = OldServer Then
On Error Resume Next
WshNetwork.SetDefaultPrinter "\\" & NewServer & "\" & _
ShareName(DefaultPrinter)
'If Err.Number = -2147352567 Then
'MsgBox "Your default printer did not exist, and has been deleted.", _
' vbOKonly + vbInformation, "Invalid default printer"
'End If
On Error goto 0
End If
End Sub ' MovePrinters

 
Function GetDefaultPrinter()
' Returns the UNC path to the current default printer
Dim oShell, sRegVal, sDefault
Set oShell = CreateObject("WScript.Shell")
sRegVal = _
"HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
sDefault = ""
On Error Resume Next
sDefault = oShell.RegRead(sRegVal)
sDefault = Left(sDefault ,InStr(sDefault, ",") - 1)
On Error Goto 0
GetDefaultPrinter = sDefault
End Function
 
 
Function ServerName(sPrinterPath)
Dim aPrinterPath
ServerName = ""
If Left(sPrinterPath, 2) = "\\" Then
aPrinterPath = Split(sPrinterPath, "\")
ServerName = aPrinterPath(2)
End If
End Function
 
 
Function ShareName(sPrinterPath)
Dim aPrinterPath
ShareName = ""
If Left(sPrinterPath, 2) = "\\" Then
aPrinterPath = Split(sPrinterPath, "\")
ShareName = aPrinterPath(3)
End If
End Function
'--------------------8<----------------------

 

This code will just move individual printers and can be to to and from the same fileserver

' #############################################################################
' Written in VBScript.
' Name: PrintSVRMigrate.vbs
' Author: .:. 24-Jul-2005
' Purpose: Modify Printer Connections
' Comment: Edit this file as neccessary, before making available to users.  
'   Comment out any lines not needed.  Only things you should need To
'   modify are the printer paths.  Read comments before each line of
'   code to see what it's doing.
' ############################################################################
'
' ==========================================
' Declaring variables - Declare everything!
' This ensures we only use variables that we
' mean to - do not modify.
' ==========================================
Option Explicit
Dim WshNetwork
 
Dim objNetwork
Dim colprinters
Dim PrinterName
Dim i
Dim oldPrinter 
Dim newPrinter
Dim printerfound
 
' Get a list of currently connected printers 
' and scan for the ones we need to change. 
' Process each printer as it is found.

Set objNetwork = WScript.CreateObject("WScript.Network")
Set colPrinters = objNetwork.EnumPrinterConnections
For i = 0 to colPrinters.Count -1 Step 2
  printerfound = "no"
' Old printer share will be case sensitive.
 If colprinters.Item (i + 1) = "\\printerserver\oldprinter" Then 
     oldPrinter = "\\printerserver\oldprinter"
     newPrinter = "\\printerserver\newprinter"
     printerfound = "yes"
 End If
 
If printerfound = "yes" Then
   SwapPrinter
End If
 
Next
 
 
WScript.Echo "Printer conversion is now complete"
 
WScript.quit
 
'*****************************
' Begin Subroutines
'*****************************

'******************
Sub  SwapPrinter 
 
Set WshNetwork = CreateObject("WScript.Network")
 
 
 
' This line will add the specified printer. You can add more printers if needed.
WshNetwork.AddWindowsPrinterConnection newPrinter
 
' This line sets the user's default printer.
' WshNetwork.SetDefaultPrinter $newPrinter

' This line removes the specified printer.
WshNetwork.RemovePrinterConnection oldPrinter
 
' If any steps are not needed, comment them out by adding a single quote to the 
' beginning of a line - like this one.

End Sub

 

 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...