Question

  Asked: Jul 5 2006   3:13 AM GMT
  Asked by: ladrick


Installing Printers Based on Active Directory Group


Microsoft Windows, Networking, Network testing, Remote management, Development, Help Desk, DataCenter, Tech support, Hardware, Software

Hi All,

I'm looking to install all my printers based on security groups within active directory I was planning on using the script below:

*** START SCRIPT PRINTERS.VBS ***

Const IT_GROUP = "IT"

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysinfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

ON ERROR RESUME NEXT

If InStr(strGroups, IT_GROUP) Then

WshShell.Run ("cscript c:windowssystem32prnport.vbs -a -o raw -r IP_192.168.0.10 -h 192.168.0.10")
WshShell.Run ("cscript c:windowssystem32prnmngr.vbs -a -p "The IT HP Laser" -m "hp LaserJet 1320 PCL 6" -r "IP_192.168.0.10")

End If

** END SCRIPT PRINTERS.VBS ***

This would work all well and good but my problems lies in this line:

WshShell.Run ("cscript c:windowssystem32prnmngr.vbs -a -p "My HP Printer" -m "hp LaserJet 1320 PCL 6" -r "IP_192.168.0.10")

Because when WshShell.Run gets to "My HP Printer" it assumes that that is the end of the command instead of after "IP_192.168.0.10" which is due to the cscript prnmngr.vbs using " " to specify The printer name, driver and IP Port.

Basically....I'm looking for way to install TCP/IP Printers based on group....I know there is quite a few ways to do this using shares i.e. \servernameprintershare but not IP Ports.....

Looking for further ideas or a way to run my problematic line...

Any thoughts ideas are welcomed

Thanks in Advance :-)

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



If this is a batch script, you can escape double-quotes by wrapping them is another pair of double-quotes.

For example your problem line:

WshShell.Run ("cscript c:windowssystem32prnmngr.vbs -a -p "My HP Printer" -m "hp LaserJet 1320 PCL 6" -r "IP_192.168.0.10")

may well work if you use:

WshShell.Run (""cscript c:windowssystem32prnmngr.vbs -a -p "My HP Printer" -m "hp LaserJet 1320 PCL 6" -r "IP_192.168.0.10"")

note to two double-quotes before cscrpit and after the IP address.

Regards
Spike
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Microsoft Windows, Networking and Development.

Looking for relevant Microsoft Windows Whitepapers? Visit the SearchWinIT.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

ladrick  |   Jul 5 2006  8:47PM GMT

No doesn’t work I tried:

WshShell.Run (”"cscript c:windowssystem32prnmngr.vbs -a -p “My HP Printer” -m “hp LaserJet 1320 PCL 6″ -r “IP_192.168.0.11″”)

The script thinks it ends at WshShell.Run (”" the second ” so it doesnt get a chance to run “cscript c:windowssystem32prnmngr.vbs -a -p “My HP Printer” -m “hp LaserJet 1320 PCL 6″ -r “IP_192.168.0.11″

Damn I wish I was a better coder….

Thanks anyway though…

Anyone else got any ideas for automatically installing tcp/ip printers based on group?

 

ELPUEBLO  |   Jul 17 2006  7:24PM GMT

I had to 1st map the IP Printer to a specific computer then 2)share it from that computer”

If you find anything I’d also be interested in this

 

dwiebesick  |   Jul 19 2006  8:59AM GMT

Have you submitted this question to Microsoft’s The Scripting Guys?

See TechNet <a href="http://www.microsoft.com/technet/scriptcenter/hubs/ad.mspx" rel="nofollow">http://www.microsoft.com/technet/scriptcenter/hubs/ad.mspx</a>
or submit it to
<a href="mailto:scripter@microsoft.com.">scripter@microsoft.com.</a>

Best of luck and keep up informed in this forum.

dmw