Solved

Scripting the addition of  network prnter

Posted on 2006-07-17
24
328 Views
Last Modified: 2008-02-01
Looking for an easy script to add a network printer. I've tried a few but keep getting "permission denied" in a vbs window. Lookslike I need a username and password somewhere when it adds the printer.
0
Comment
Question by:prlit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 5
  • 3
  • +2
24 Comments
 
LVL 13

Expert Comment

by:haim96
ID: 17125762
if you don't have permission to add the printer it's mean that you need
to supply user + pass within the script (probably admin's )
and i'm not sure you want to do that ...
any way, is this  network printer connected with network card
or it's shared on via network computer ?
if it's connected with network card you need to be admin
because it require driver installation.
if it's only shared (and security is defualt) most of the time you don't need to be admin ....
0
 
LVL 1

Author Comment

by:prlit
ID: 17126148
No, it's shared from another PC and I'd like to supply the login info within the script.

Thanks
0
 
LVL 3

Expert Comment

by:danishtahir
ID: 17126367
Can you post your script?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:prlit
ID: 17126566
Copy & paste the following into a text editor and save with a .vbs extension.

'// Name: setprint.vbs
'// Description: Add a network printer and make it the default

Set WshNetwork = CreateObject("WScript.Network")

'// Adds the printer. Substitute your server name and printer share.
WshNetwork.AddwindowsPrinterConnection "\\Server\printer"

'// Makes the specified printer the default.
WshNetwork.SetDefaultPrinter "\\Server\printer"
 

Also:


'
' Printers.vbs - Windows Logon Script.
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\alan\Epson."



Also tried:
' Guy Thomas February 2004.
' ******************************
Option Explicit
Dim netPrinter, UNCpath
UNCpath = "\\YourServer\PrinterName"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath
WScript.Echo "Your printer is mapped from : " & UNCpath
WScript.Quit
' End of example VBScript


Always get permission denied.
0
 
LVL 3

Expert Comment

by:danishtahir
ID: 17126872
If you click on start, then in run type

\\alan\Epson

what happens?
0
 
LVL 1

Author Comment

by:prlit
ID: 17126889
it prompts me for a user/pass
0
 
LVL 3

Expert Comment

by:danishtahir
ID: 17127044
so, it means that you will need to configure a username/password you have on the host machine identical to the one where you are connecting from. This should solve your problem.
0
 
LVL 1

Author Comment

by:prlit
ID: 17127066
but there's no way to include it in the script? We're talking over 150 Pc's
0
 
LVL 13

Expert Comment

by:haim96
ID: 17132709
it's a domain network ? or workgroup ?
0
 
LVL 13

Expert Comment

by:haim96
ID: 17132869
any way , try to combine the add printer from command line from here :
http://www.windowsitpro.com/Article/ArticleID/14539/14539.html?Ad=1

with the "runas" command. ( type "runas /?" int cmd window to get full syntex )
this should alow you to add network printer with alternative credentials
0
 
LVL 1

Author Comment

by:prlit
ID: 17132967
it's a workgroup.
0
 
LVL 13

Expert Comment

by:haim96
ID: 17133049
try this:
c:\runas /user:server\admin "rundll32 printui.dll,PrintUIEntry  /in /n\server\printer" <pass.txt

when:
server= the computer with the printer
admin = your admin user
printer = printer name
pass.txt = text file that contain the admin password


0
 
LVL 1

Author Comment

by:prlit
ID: 17133462
so: c:\runas /administrator:192.168.1.67\admin "rundll32 printui.dll,PrintUIEntry  /in /n\192.168.1.67\WinPrint1" <pass.txt
0
 
LVL 1

Author Comment

by:prlit
ID: 17133467
system cannot find the file specified.
0
 
LVL 13

Accepted Solution

by:
haim96 earned 500 total points
ID: 17133503
because you need to create it  :)
create file named pass.txt with your password (no extra lines,spaces etc) and save it in c:\
and it's :
c:\runas /user:192.168.1.67\administrator "rundll32 printui.dll,PrintUIEntry  /in /n\192.168.1.67\WinPrint1" <pass.txt
0
 
LVL 1

Author Comment

by:prlit
ID: 17133561
'C:\runas' is not recognized as an internal or external command, operable program or batch file.
0
 

Expert Comment

by:bgssgk
ID: 17133694
what operating system is the client machine, the runas command may not be available
0
 
LVL 1

Author Comment

by:prlit
ID: 17133988
Windows XP Pro SP2
0
 
LVL 1

Author Comment

by:prlit
ID: 17133996
It's there - if I type runas - I get all of the info for the cmd.
0
 
LVL 1

Author Comment

by:prlit
ID: 17134062
I know what I did wrong. I got it go go farther

runas /user:PRINTSERVER2\administrator "rundll32 printui.dll,PrintUIEntry  /in /n\192.168.1.67\WinPrint1" <pass.txt

enter the password for PRINTSERVER2\administrator:

then it says attempting to start rundll32 printui.dll,PrintUIEntry  /in /n\192.168.1.67\WinPrint1" as user PRINTSERVER2\administrator

then I get a logon failure. My pass.txt file just has the password in it - nothing else.
0
 
LVL 1

Author Comment

by:prlit
ID: 17134087
Is one of those usernames from my printing host or both?
0
 
LVL 1

Expert Comment

by:JexPam
ID: 17134698
My best advice- Get a network card (can be an external adapter such as the HP Jetdirect 170x Print Server) for the printer and then install the printer local on every workstation pointing to its IP address.
This is a preventative step to the countless “I cant print” support requests because the host workstation is turned off.

As for the current host workstation – make sure File and print sharing is enables and enabled in the firewall.
Go into control panel > User accounts; and create a user for the share access. Something like “printer / printer” and grant it whatever permission level you want (in the local groups).

Also make sure the user on the workstation you are trying to install the printer on has greater than “User” permission for the install to be successful.
0
 
LVL 1

Author Comment

by:prlit
ID: 17134729
We're talking 9 printers as well. That would get expensive. I just need a quick and easy way to share them to a PC.
0
 
LVL 1

Author Comment

by:prlit
ID: 17268496
That worked.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally Windows/Microsoft Updates will fail to update. We have found a code that will delete all temporary files and re-register all dll's related to Windows/Microsoft Updates! This works 99% of the time to get the updates working again! The…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

628 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