200 users need the same list of network printers

SR Zak
SR Zak used Ask the Experts™
on
Hi Experts.

I need a vbs script or batch file that will have netowork admin and password and will help me walk around and add 10-15 network printers on 200 desktops. I can not think of an easy way.

Can you help.

Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If they are a member of a domain just use Group Policy Preferences.

http://blogs.technet.com/b/grouppolicy/archive/2009/06/24/gp-preferences-set-a-default-printer.aspx

If not, here is the VBS code that I currently use to add network printers in my network.  This will have to be run as the user that needs them.

addprinterconnection("\\servername\printer1")
addprinterconnection("\\servername\printer2")
addprinterconnection("\\servername\printer3")


Function AddPrinterConnection(PrinterPath)

	On Error Resume Next
	Set WSNetwork1 = CreateObject("WScript.Network") 
	
	WSNetwork1.AddWindowsPrinterConnection(PrinterPath)
	
	AddPrinterConnection = True
	If Err.Number = 0 Then
		WriteToEventLog "Sucessfully Mapped " & PrinterPath,0
	Else
		WriteToEventLog "Failed to map " & PrinterPath & " to " _
		& " with the following error." _
		& Chr(13) & Chr(10) & Chr(10) _
		& Err.Description, 1
	End If
	
End Function

Open in new window

TunerMLSystems Engineer

Commented:
The only thing I can thin k of is to use per machine connections, from command promt rundll32 printui.dll,PrintUIEntry /?. I would have to refresh myself on the use of this command before getting more detailed. But in my enviroment it's extremely helpful as users don't have permissions to install drivers.
SR ZakNetwork Solutions

Author

Commented:
But the problem is when I run it as the user he is asked to pur credentials for the print server that is on different domain. I can only see the print queue when the credentials are entered. Can you please input the sytax for domain\administrator and password: Jumncy. This is just an example. I need to add the domain admin account and password to this script inorder for the user to add the printers successfully.

Thanks,
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

I updated the code to accept a username and password. I did not have a chance to test it but it should work fine.  Let me know.
addprinterconnection("\\servername\printer1","domain\jsmith","!password!")
addprinterconnection("\\servername\printer2","domain\jsmith","!password!")
addprinterconnection("\\servername\printer3","domain\jsmith","!password!")


Function AddPrinterConnection(PrinterPath,username,password)

	On Error Resume Next
	Set WSNetwork1 = CreateObject("WScript.Network") 
	
	WSNetwork1.AddWindowsPrinterConnection(PrinterPath,true,username,password)
	
	AddPrinterConnection = True
	If Err.Number = 0 Then
		WriteToEventLog "Sucessfully Mapped " & PrinterPath,0
	Else
		WriteToEventLog "Failed to map " & PrinterPath & " to " _
		& " with the following error." _
		& Chr(13) & Chr(10) & Chr(10) _
		& Err.Description, 1
	End If
	
End Function

Open in new window

SR ZakNetwork Solutions

Author

Commented:
Thanks I will try it and will let you know.

Commented:
If you want to use PowerShell I had some successful tests with this:
$net = new-Object -com Wscript.Network

gc "printers.txt" | % {$net.AddWindowsPrinterConnection($_,"username","password")}

Open in new window

SR ZakNetwork Solutions

Author

Commented:
Joef12345,

I added a sharename and domain account to your script but I get the error message on line 1 character 75. Error cannot use parentheses when calling a Sub.

do you know what that means.
SR ZakNetwork Solutions

Author

Commented:
When I remove parentheses from Line 1 , 2, and 3. I get the error on line 11 Char 76 Error: Cannot use parentheses when calling a Sub

Thanks,
SR ZakNetwork Solutions

Author

Commented:
Sorry Vaulden we are not that advance to work on powershell yet.
SR ZakNetwork Solutions

Author

Commented:
what about a windows batch file?

Commented:
What OS are the clients running?
SR ZakNetwork Solutions

Author

Commented:
Fixed the script on my own plus the expert did not respond again

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial