Installing Printers Based on Active Directory Group

pts.
Tags:
DataCenter
Development
Hardware
Help Desk
Microsoft Windows
Network testing
Networking
Remote management
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 :-)

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Ladrick
    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?
    0 pointsBadges:
    report
  • ELPUEBLO
    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
    0 pointsBadges:
    report
  • Dwiebesick
    Have you submitted this question to Microsoft's The Scripting Guys? See TechNet http://www.microsoft.com/technet/scriptcenter/hubs/ad.mspx or submit it to scripter@microsoft.com. Best of luck and keep up informed in this forum. dmw
    2,235 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following