We help IT Professionals succeed at work.

Moving from a Windows 2003 to 2008 Print Server.  Need a script

309 Views
Last Modified: 2012-05-08
Our current printserver is on windows server 2003.  I just finished setting up a server 2008 print server and have configured all our printers on that new server.  I would now like to create a script I can run on the clients at logon that will find their existing printer by name, delete it and install the printer again off the new server.  Basically looking for a printer find and replace.  Not all users have the same printers attached to their computer so if the printer is not found the script should continue.  The computers are running windows 2000 and windows Xp.  Can someone provide a template script that would accomplish my task?
Comment
Watch Question

Hi,

You can get a good idea by this: https://www.experts-exchange.com/Programming/Languages/Scripting/Q_24262599.html

Regards,
Faraz H. Khan
small script, should do the trick
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
 
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer Where Local = FALSE")
 
For Each objPrinter in colPrinters
    'objNetwork.RemovePrinterConnection objPrinter.Name, true, true 'remove queue
    temp = Split(Mid(objPrinter.Name,3,len(objPrinter.Name)-2), "\") 'strip server name and slash out
    strPrinterName = temp(1) 'set Name
    objNetwork.AddWindowsPrinterConnection "\\servername\" & strPrinterName 'add it using new server name
Next

Open in new window

Author

Commented:
TheNautican,
I am not sure I understand your script.  Given the following can you complete the script:
older printer: \\oldserver\printerold
new printer: \\newserver\printernew
 
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
That worked partially.  I have 8 Canon and 4 HP network printers.  All the printers were removed and only the 8 Canons were replaced from the new server.  None of the 4 HP printers were added back.  The share names are the same on both servers.  Any ideas?
could be in the way their names get split.
run this on a machine to be migrated using the command line
Cscript whatever.vbs make sure the output is correct.
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
 
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer Where Local = FALSE")
 
For Each objPrinter in colPrinters
    'objNetwork.RemovePrinterConnection objPrinter.Name, true, true 'remove queue
    temp = Split(Mid(objPrinter.Name,3,len(objPrinter.Name)-2), "\") 'strip server name and slash out
    strPrinterName = temp(1) 'set Name
    Wscript.Echo "Full Name: " & objPrinter.Name & "  " & "Print Queue: " & strPrinterName
    'objNetwork.AddWindowsPrinterConnection "\\servername\" & strPrinterName 'add it using new server name
Next

Open in new window

i find the last script good, it should do the work.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.