I'm not a great vbscripter, but I play one on the internet sometimes :)
Your script looks like this:
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\servername\Boston_IT2"
strConnectString = "\\servername\Boston_IT"
strResult =objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
Since vbscript runs in serial (that is, it executes top to bottom) you're
setting the variable strConnectString first to \\Servername\Boston_IT2 and
then overwriting it to \\Servername\Boston_IT. The result is that you are
creating the printer last specified before the execution: strResult
=objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
To do what you want, you need either a list to pull from (are you reading
these printers in?) else you'll need to run it multiple times within the
script.
I'm assuming you already know what the printers are, so something like this
would work:
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
'Create First Printer
strConnectString = "\\servername\Boston_IT2"
strResult =objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
'Create Second Printer
strConnectString = "\\servername\Boston_IT"
strResult2 =objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
And so on...
Not sure what value strResult and StrResult2 provide in this script exactly,
but I left them as unique values so you could check that value later if you
wanted to. Here's a reference to it on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/wsmthaddwindowsprinterconnection.asp
Al
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christine Allen
Sent: Tuesday, April 12, 2005 4:19 PM
To: '[email protected]'
Subject: [ActiveDir] VB Script and Group policy
Running Windows 2000 AD
I'm looking to automate the installation of printers using a vb script and
group policy. I found the script referenced below which works great for
adding the printer and works great with GP. However, I can only add one
printer. Every time I modify it to add additional printers it only adds
one.
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\servername\Boston_IT2"
strConnectString = "\\servername\Boston_IT"
strResult =objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
Does anyone out there know a way of additional multiple printers with this
script? I should mention I am not a vb person.
Thanks
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/