Solved

remap network printers using a batch file.

Posted on 2006-07-17
17
856 Views
Last Modified: 2009-02-24
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

0
Comment
Question by:jasonleethompson
  • 6
  • 5
  • 5
  • +1
17 Comments
 
LVL 13

Expert Comment

by:prashsax
ID: 17125333
Its a VBScript which install the printer.

http://support.microsoft.com/kb/263226/en-us
0
 
LVL 13

Expert Comment

by:prashsax
ID: 17125421
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
-------------------------------------------------------------------------
0
 
LVL 12

Expert Comment

by:NetAdmin2436
ID: 17125522
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!!!)
http://www.experts-exchange.com/Programming/Q_21740001.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.
0
 
LVL 1

Author Comment

by:jasonleethompson
ID: 17125676
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?
0
 
LVL 13

Expert Comment

by:prashsax
ID: 17125763
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.
0
 
LVL 12

Expert Comment

by:NetAdmin2436
ID: 17125814
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.
0
 
LVL 13

Expert Comment

by:prashsax
ID: 17125878
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.

0
 
LVL 1

Author Comment

by:jasonleethompson
ID: 17125992
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
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:prashsax
ID: 17126018
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.
0
 
LVL 1

Author Comment

by:jasonleethompson
ID: 17126043
Thanks That worked... Error on exacution:

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

Any ideas?

THANKS
0
 
LVL 12

Expert Comment

by:NetAdmin2436
ID: 17126054
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.
0
 
LVL 1

Author Comment

by:jasonleethompson
ID: 17126057
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?
0
 
LVL 13

Expert Comment

by:prashsax
ID: 17126073
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.
0
 
LVL 12

Accepted Solution

by:
NetAdmin2436 earned 500 total points
ID: 17126108
arPrt = array("\\myserver\ausaprn07", _
                    "\\myserver\ausaprn10", _
                    "\\myserver\ausaprn08", _
                    "\\myserver\ausaprn09", _
                    "\\myserver\ausaprn13", _
                    "\\myserver\ausaprn04", _
                    "\\myserver\ausaprn02")

Line 6 had an extra \ infront of the server and a missing \ before the printer

Try that.
0
 
LVL 1

Author Comment

by:jasonleethompson
ID: 17126144
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
0
 
LVL 12

Expert Comment

by:NetAdmin2436
ID: 17126223
Rock on! (first time i've been called a bad ass on here)

You can just go and 'split points'
http://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.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17128233
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
0

Featured Post

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Join & Write a Comment

What is IRC? IRC (Internet Relay Chat) is a form of communication between multiple users. It is available freely to anyone with inernet access. IRC is a great way to communicate with others e.g. There is an IRC channel for Ubuntu Linux, which is fo…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now