Hello,
I am trying to write a vbs script that replaces the need for the user to
connect printers by right-clicking a printer and choosing 'connect'. I am
using the following code:

' declare variables
dim wshnetwork

' set reference to WSH network object
set wshnetwork=wscript.createobject("wscript.network")

' add connection to a network printer hpintel on samba (ibm-nas)
wshnetwork.addwindowsprinterconnection "\\samba\hpintel"

The problem is that the printer is on samba and I am trying to connect to it
as a local administrator. The way I would do it manually is connect to
\\samba and enter my login and password in the domain and then 'connect' the
printer. However, if I were to run the script as an administrator I
wouldn't have the opportunity to authenticate with samba. Therefore I tried
using the "runas" command to run the script as a domain user. I used the
/netonly option. This worked as far as the printers showing up on the
"printers and faxes" window. But they appeared with the status: "access
denied. unable to connect" and when I tried to print I got the error
message: "Cannot print the file. Be sure that your printer is connected
properly and use Control Panel to verify that the printer is configured
properly."

What should I do? Is there any way to simulate connecting to samba as a
known domain user and then adding printers?

Thanks,
Aviv.

Re: connecting printers on samba in a vbs script? by Aviv

Aviv
Mon Aug 16 08:25:53 CDT 2004

More info: When I try to run the vbs script as local administrator I get a
vb script error stating "permission denied". That's why I had to resort to
using the "runas". Is there a way to connect a printer as a domain user in
a script?
Aviv


"Aviv Gurwitz" <temp1604@hotmail.com> wrote in message
news:cfqc63$vea$1@news.iucc.ac.il...
> Hello,
> I am trying to write a vbs script that replaces the need for the user to
> connect printers by right-clicking a printer and choosing 'connect'. I am
> using the following code:
>
> ' declare variables
> dim wshnetwork
>
> ' set reference to WSH network object
> set wshnetwork=wscript.createobject("wscript.network")
>
> ' add connection to a network printer hpintel on samba (ibm-nas)
> wshnetwork.addwindowsprinterconnection "\\samba\hpintel"
>
> The problem is that the printer is on samba and I am trying to connect to
it
> as a local administrator. The way I would do it manually is connect to
> \\samba and enter my login and password in the domain and then 'connect'
the
> printer. However, if I were to run the script as an administrator I
> wouldn't have the opportunity to authenticate with samba. Therefore I
tried
> using the "runas" command to run the script as a domain user. I used the
> /netonly option. This worked as far as the printers showing up on the
> "printers and faxes" window. But they appeared with the status: "access
> denied. unable to connect" and when I tried to print I got the error
> message: "Cannot print the file. Be sure that your printer is connected
> properly and use Control Panel to verify that the printer is configured
> properly."
>
> What should I do? Is there any way to simulate connecting to samba as a
> known domain user and then adding printers?
>
> Thanks,
> Aviv.
>
>