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?