connecting printers on samba in a vbs script?

From: Aviv Gurwitz (
Date: 08/16/04

Date: Mon, 16 Aug 2004 16:17:55 +0300

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("")

' 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

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


Relevant Pages

  • Re: dialup solution (as seconary connection / iptables )
    ... ip-down is launched by pppd only after the PPP link no longer available ... first with MINICOM or is PAP and script not mutualy exclusive? ... do have to "make the connection first with MINICOM." ... If you use the Linux box and route the news IP address to it on each ...
  • SMB.CONF without plenken
    ... # This is the main Samba configuration file. ... # unix names. ... # add user script delete user script etc etc ... # Each logon script should be stored at the base of the share. ...
  • Re: mysqli connections and oop
    ... need to do all processing in a script before I display a page that will ... But it will most probably NOT terminated the execution of the script. ... this means that NO lasting connection is build ... Why does it not carry the mysqli connection? ...
  • Re: mysqli connections and oop
    ... And here is the script that execute this ... lose a mysqli connection upon the reload of the page? ...
  • Re: Does apache stop a script mid execution ?
    ... If the user calls a time consuming script and then stops or refreshes ... How does it relate to e.g. a script performing a large mysql query? ... 2.b) how the connection is set up. ... the server stops the script execution. ...