From: inenewbl on
Hi all,

There are staff from other overseas sites that fly over to my branch office
often and they need to map printers. Their notebks are join to different
domain as my branch office. Is it possible for them to map a printer via ip
address directly using vb script? thks in advance.
From: Marten on
We have consultants that bring their own laptops into our offices. If
I connect them straight to the printer's IP, they would be bypassing
the print server and therefore have to manually install the print
driver.

I haven't tried this, but how about creating a generic user in your AD
that only has access to the printers. In your script do a .exec with
'net use lpt3 \\printserver\share password /user:domain\PrintOnlyUser'
That should connect the generic account to the print server and then
allow you to continue with WshNetwork.AddWindowsPrinterConnection to
install printers. I used LPT3 because I doubt there are many laptops
with 3 physical printer ports.

Marten


On Mon, 12 Jul 2010 20:17:03 -0700, inenewbl
<inenewbl(a)discussions.microsoft.com> wrote:

>Hi all,
>
>There are staff from other overseas sites that fly over to my branch office
>often and they need to map printers. Their notebks are join to different
>domain as my branch office. Is it possible for them to map a printer via ip
>address directly using vb script? thks in advance.

From: Shenan Stanley on
inenewbl wrote:
> There are staff from other overseas sites that fly over to my
> branch office often and they need to map printers. Their notebks
> are join to different domain as my branch office. Is it possible
> for them to map a printer via ip address directly using vb script?
> thks in advance.

Can they map it directly manually?

If so - then the answer to your question about scripting it would be "yes".
If they cannot map it manually (or you cannot remote into their machine and
knowing how to do it - do it yourself manually) then the scripting is not
going to help matters.

--
Shenan Stanley
MS-MVP
--
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html


From: James Whitlow on
"inenewbl" <inenewbl(a)discussions.microsoft.com> wrote in message
news:B7FD9D14-901E-43C8-A1A2-0F0DAF060466(a)microsoft.com...
> Hi all,
>
> There are staff from other overseas sites that fly over to my branch
> office
> often and they need to map printers. Their notebks are join to different
> domain as my branch office. Is it possible for them to map a printer via
> ip
> address directly using vb script? thks in advance.

Assuming you already have the printer driver installed on the computer,
you can use something like the code posted below. The code will throw an
exception if the printer drive is not already installed.

If the driver is not installed and you need to install it. Reply back and
I or someone else in the group will post a function to install a printer
driver. However, since you mentioned that these visitors were not on your
domain, you would need to put the installation files somewhere that they
could access them (share with guest access?). Putting the script and the
drivers onto a CD-ROM might work...

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim sIP
sIP = "10.1.2.3"
If CreateIPPort(sIP) = True Then
AddPrinter "Test Printer", sIP, "HP LaserJet 5"
End If

Function CreateIPPort(ByVal sIP)
Dim oWMI, oPort, i
CreateIPPort = False
On Error Resume Next
Set oWMI = GetObject("WinMgmts:/root/cimV2")
Set oPort = oWMI.ExecQuery("SELECT * FROM Win32_TCPIPPrinterPort" _
& " WHERE HostAddress='" & sIP & "'")
For Each i in oPort
i.Delete_
Next
Set oPort = oWMI.Get("Win32_TCPIPPrinterPort").SpawnInstance_
oPort.Name = sIP
oPort.Protocol = 1
oPort.HostAddress = LCase(sIP)
oPort.SNMPEnabled = False
oPort.Put_
Set oPort = oWMI.ExecQuery("SELECT * FROM Win32_TCPIPPrinterPort" _
& " WHERE HostAddress='" & sIP & "'")
CreateIPPort = cBool(oPort.Count = 1)
End Function

Function AddPrinter(ByVal sName, ByVal sPort, ByVal sModel)
With GetObject("winmgmts:\root\cimv2").Get("Win32_Printer")._
SpawnInstance_
.DriverName = sModel
.Portname = sPort
.DeviceID = sName
.Put_
End With
AddPrinter = Err.Number
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~