Link to home
Start Free TrialLog in
Avatar of jasonleethompson
jasonleethompson

asked on

remap network printers using a batch file.

I have 250 users that all use the same print server. We are bringing this server down and need a way to remap all of there network printers over to the new server.

I am thinking create a batch file that I can push out using group polices.

They all use Adobe writer and this one is the only one that needs to stay.

Thanks

Avatar of prashsax
prashsax

Its a VBScript which install the printer.

http://support.microsoft.com/kb/263226/en-us
Here is one more Script.
It will install the printer and set it as default as well.
Just change SERVER_NAME and PRINTER_NAME in the script.
--------------------------------------------------------------------------
Option Explicit
Dim objNetwork, strUNCPrinter
strUNCPrinter = "\\SERVER_NAME\PRINTER_NAME"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter

' Here is where we set the default printer to strUNCPrinter
objNetwork.SetDefaultPrinter strUNCPrinter
WScript.Echo "Check the Printers folder for : " & strUNCPrinter

WScript.Quit
-------------------------------------------------------------------------
Better yet is this script which will purge old printer connections and add new ones. You can also add a line in the login script to point to the script.
This script will first purge all network printers (it will not purge locally attatched printers, i.e. adobe acrobat writer will not be deleted), then add the new network printers that you choose. Obviously change the \\Server\HPlasterJet5000PS entries to your printers on your new server. The default printer will be the y=y+1 which in the example below case is the HPColorLaserJet4600 PCL. y=y+0 would set the default to HPlaserJet5000PS and so on.

I actually got this script from a question i asked before. (thanks Sr75!!!)
https://www.experts-exchange.com/questions/21740001/Set-default-printer-on-this-vbs-script.html 

<script>
arPrt = array("\\Server\HPLaserJet5000PS", _
                    "\\Server\HPColorLaserJet4600PCL5c", _
                    "\\Server\Canon iR1600-2000 (FAX)", _
                    "\\Server\Canon iR1600-2000 PCL5e", _
                    "\\Server\HP DesignJet 800 24 by HP", _
                    "\\Server\hpLaserJet1300_PCL5e", _
                    "\\Server\HP LaserJet 6L")

Set wshNet = CreateObject("WScript.Network")
Set wshPrn = wshNet.EnumPrinterConnections
For x = 0 To wshPrn.Count - 1 Step 2
    If Left(wshPrn.Item(x+1),2) = "\\" Then wshNet.RemovePrinterConnection wshPrn.Item(x+1),True,True
Next
On Error Resume Next

y = 0

Do until y = 6
           wshNet.AddWindowsPrinterConnection(arPrt(y))
           y = y +1
loop

wshNet.SetDefaultPrinter arPrt(1)
<end script>

Hope this helps.
Avatar of jasonleethompson

ASKER

Much thanks for your help, is there not just a simple batch file that I can run. I am by no means a programer. Plus even to make this a exeacutable you would need to rename it to .vbs?
Yes, you would need to rename it to .vbs

Also, you don't have to do much in the script.

Just change the SERVER_NAME with the name of your printer server.

Also change the PRINTER_NAME with the shared printer name.

you can find the printer name by opening the shares on the print server.

START->RUN->\\SERVER_NAME

This will open the window with printer named mentioned in it.
You don't need any programming knowledge really. Just open up notepad. Copy the above script from <script>  and everything in between to <end script>. Then go file --> save as --> scriptname.vbs

Save this to a place on your server where all user have access to it.
Hi NetAdmin,

I can't understand the script you have given here.

How does this script would know the Print Server name and the printer name to install.

Also, what does array arPrt does. It holds lots of printer name, but for what.
How would you know that all these printers exists on the print server.

I replaced the script with my networked printers and servers names. Right clicked on it and said rename. Renamed it "prntmig.vbs"  It still looks like a text document? What did I do wrong? Thanks
You must have Hide Known filename enabled.

So, the real filename is prntmig.vbs.txt

Now open this file in notepad.
Click SaveAs
Now give filename as "prntmig1.vbs"

Remeber to give the name with quotes other wise notepad will append .txt again.
Thanks That worked... Error on exacution:

line 1
char 1
error: expected statement
code: 800A0400
source m$ vbscript compilation error

Any ideas?

THANKS
Prashsax-
This was an example script (ie.they exist on my print server). He will have to change \\Server\HPLaserJet5000PS to his actual printer on his new server.

>>How does this script would know the Print Server name and the printer name to install.
Re-read my first post. In my first post i said "Obviously change the \\Server\HPlasterJet5000PS entries to your printers on your new server." This is just like your script in the sense you need to change \\Server\PrinterName to the actual name of your server and printer.

>>Also, what does array arPrt does. It holds lots of printer name, but for what. How would you know that all these printers exists on the print server.
arPrt is ued if you have lots of printers that you want to add, it basically just makes the script shorter.
arPrt = array("\\myserver\ausaprn07", _
                    "\\myserver\ausaprn10", _
                    "\\myserver\ausaprn08", _
                    "\\myserver\ausaprn09", _
                    "\\myserver\ausaprn13", _
                    "\\\myserverausaprn04", _
                    "\\myserver\ausaprn02")

Notice the change in line 1   is the ( the error?
kool, I just missed on the replace the name part.
Thanks.

jasonleethompson you have copied the script starting from
"Option Explicit " only.

If yes, then try and remove first line.
If no, make it the first line and WScript.Quit the last.
ASKER CERTIFIED SOLUTION
Avatar of NetAdmin2436
NetAdmin2436
Flag of United States of America image

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
you guys are so bad ass. Makes me want to hit the books. I am such a wannabee............Thanks , Hell you all get the points. Let me know how to do this. THANKS
Rock on! (first time i've been called a bad ass on here)

You can just go and 'split points'
https://www.experts-exchange.com/help.jsp#hi69

There's many books as well as free scripts on windows scripting on the internet, just google it. Or my personal favorite, just hit up experts-exchange and ask for one. Scripts will save you hours and hours of work; especially with 250 users!

Glad we could help.
Avatar of Steve Knight
Just another idea for the pot...

You could also just add an alias in DNS for the new server --> enter a CNAME for oldserver which points to newserver instead of it's old A record.

Now when anyone accesses \\oldserver they will get to \\newserver.

Test it by adding a CNAME of printtest pointing at newserver and then you should be able to use \\printtest\yourprinters.

Might need to turn off strict name checking on the server but try it and see if you wish...

Steve