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

Windows BatchPrinters and ScannersWindows Server 2003

Avatar of undefined
Last Comment
Habi Z

8/22/2022 - Mon

If they are a member of a domain just use Group Policy Preferences.


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.


Function AddPrinterConnection(PrinterPath)

	On Error Resume Next
	Set WSNetwork1 = CreateObject("WScript.Network") 
	AddPrinterConnection = True
	If Err.Number = 0 Then
		WriteToEventLog "Sucessfully Mapped " & PrinterPath,0
		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


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.
Habi Z

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.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Habi Z

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

Habi Z


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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Habi Z

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

Habi Z

Sorry Vaulden we are not that advance to work on powershell yet.
Habi Z

what about a windows batch file?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

What OS are the clients running?
Habi Z

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