Printer Migration



Here in Our Site, We just update to Server 2012 Print Server. We are vbscript for netlogon. Here is my Dilemma, I have to Move all the user and map thier Printer to the new 2012 Server. here is a script I found... If someone can help me that would be great...



'Replace mapped printers from one print server to another 
'Shared printers on new server must have identical printer sharenames as printers on old server 
'Replaced and removed printers is logged in a logfile 
'Written by: Martin Berton (martin.berton@infocare.se) 
 
on error resume next 
 
Const ForReading = 1, ForWriting = 2, ForAppending = 8  
 
'======================================= 
'Here you name the servers and logfile 
'======================================= 
 
oldprintserver = "OLDSERVER" 
newprintserver = "NEWSERVER" 
logfilepath = "remapp_printers.txt" 
 
 
Set filesys = CreateObject("Scripting.FileSystemObject") 
Set filetxt = filesys.OpenTextFile(logfilepath, ForAppending, True)  
 
'Default printer is read from the registry 
Set objShell = CreateObject("WScript.Shell") 
sPath = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device" 
ar_PrnInfo = Split(objShell.RegRead(sPath), ",") 
sPrinter = "" 
  
If IsArray(ar_PrnInfo) Then 
   sPrinter = ar_PrnInfo(0) 
End If 
 
'Installed printers is read 
Set WshNetwork = WScript.CreateObject("WScript.Network") 
Set Printers = WshNetwork.EnumPrinterConnections 
 
'Checking if printers is on old print server 
For i = 0 to Printers.Count - 1  
  if UCase(Mid(Printers.Item(i), 2, Len(oldprintserver)+2)) = "\"& oldprintserver &"\" Then 
     oldprinter = Printers.Item(i) 
     newprinter = "\\" & newprintserver & "\" & Mid(Printers.Item(i), Len(oldprintserver)+4) 
 
     ' Check if printer the printer on the new print server allready is installed 
     allreadyinstalled = false 
     For j = 0 to Printers.Count - 1  
       if newprinter = Printers.Item(j) Then 
          allreadyinstalled = true 
       end if 
     Next 
 
     if allreadyinstalled then 
       'If the printer allreday is installed, the printer on the old print server will be removed 
       filetxt.WriteLine(oldprinter & " removed") 
     else 
       'If the printer is not installed, the printer on the new print server is installed 
       'and the printer on the old print server will be removed 
       filetxt.WriteLine(oldprinter & " replaced with " & newprinter) 
       WshNetwork.AddWindowsPrinterConnection newprinter 
     end if 
     WshNetwork.RemovePrinterConnection oldprinter 
 
  end if 
Next 
 
'if the users default printer is a printer on the old print server, the default printer 
'is changed to the new print server 
if UCase(Mid(sPrinter, 2, Len(oldprintserver)+2)) = "\"& oldprintserver &"\" Then 
     PrinterPath = "\\" & newprintserver & "\" & Mid(sPrinter, Len(oldprintserver)+4) 
     filetxt.WriteLine("New default printer = " & PrinterPath) 
     WshNetwork.SetDefaultPrinter PrinterPath 
 
End If 
 
filetxt.Close  
 
 
 
 -Name $printer.Name -Shared $shared -Published $published





September 10th, 2015 2:50pm

The purpose of this forum is to ask specific scripting questions, not to rewrite code you found on the Internet to meet specific specifications. If that's what you need, you would need to hire a consultant.

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 3:02pm

In WS2008 and later we use Group Policy to assign and manage printers.  We do not use logon scripts.  In fact we haven't used logon scripts since the new Print Manager was released with WS2003R2 alonk with the Group Policy Preferences engine.  What you are asking to do has been deprecated and obsolete for 10 years now.

September 10th, 2015 3:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics