Link to home
Start Free TrialLog in
Avatar of ohmErnie
ohmErnie

asked on

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

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?
Avatar of farazhkhan
farazhkhan
Flag of Pakistan image

Hi,

You can get a good idea by this: https://www.experts-exchange.com/questions/24262599/printer-Add-Delete-Batch-Script.html

Regards,
Faraz H. Khan
Avatar of TheNautican
TheNautican

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

Avatar of ohmErnie

ASKER

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
 
ASKER CERTIFIED SOLUTION
Avatar of TheNautican
TheNautican

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.