Link to home
Start Free TrialLog in
Avatar of smart Z
smart Z

asked on

200 users need the same list of network printers

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,
Avatar of joef12345
joef12345

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

Avatar of TunerML
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.
Avatar of smart Z

ASKER

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

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
Avatar of smart Z

ASKER

Thanks I will try it and will let you know.
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

Avatar of smart Z

ASKER

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.
Avatar of smart Z

ASKER

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,
Avatar of smart Z

ASKER

Sorry Vaulden we are not that advance to work on powershell yet.
Avatar of smart Z

ASKER

what about a windows batch file?
What OS are the clients running?
Avatar of smart Z

ASKER

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