Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Scripting the addition of network prnter

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
prlit
Asked:
prlit
  • 14
  • 5
  • 3
  • +2
1 Solution
 
haim96Commented:
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
 
prlitAuthor Commented:
No, it's shared from another PC and I'd like to supply the login info within the script.

Thanks
0
 
danishtahirCommented:
Can you post your script?
0
Independent Software Vendors: 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!

 
prlitAuthor Commented:
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
 
danishtahirCommented:
If you click on start, then in run type

\\alan\Epson

what happens?
0
 
prlitAuthor Commented:
it prompts me for a user/pass
0
 
danishtahirCommented:
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
 
prlitAuthor Commented:
but there's no way to include it in the script? We're talking over 150 Pc's
0
 
haim96Commented:
it's a domain network ? or workgroup ?
0
 
haim96Commented:
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
 
prlitAuthor Commented:
it's a workgroup.
0
 
haim96Commented:
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
 
prlitAuthor Commented:
so: c:\runas /administrator:192.168.1.67\admin "rundll32 printui.dll,PrintUIEntry  /in /n\192.168.1.67\WinPrint1" <pass.txt
0
 
prlitAuthor Commented:
system cannot find the file specified.
0
 
haim96Commented:
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
 
prlitAuthor Commented:
'C:\runas' is not recognized as an internal or external command, operable program or batch file.
0
 
bgssgkCommented:
what operating system is the client machine, the runas command may not be available
0
 
prlitAuthor Commented:
Windows XP Pro SP2
0
 
prlitAuthor Commented:
It's there - if I type runas - I get all of the info for the cmd.
0
 
prlitAuthor Commented:
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
 
prlitAuthor Commented:
Is one of those usernames from my printing host or both?
0
 
JexPamCommented:
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
 
prlitAuthor Commented:
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
 
prlitAuthor Commented:
That worked.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 14
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now