Script Installing Default Printers for Groups

  • Thread starter Thread starter James G.
  • Start date Start date
J

James G.

Hi,

First off, do i assume correctly it is possible to install default printers
using group policy??

Secondly, how do i do it and where can i find the info? Are there any
problems with this?

Cheers guys.

James MCP
 
Hi,

You can use the Windows Scripting host "Network" object to add printers.

To add a printer:

'**SCRIPT START
Dim oWshnetwork 'Declare a variable (not neccesary in Windows scriptinh
edition, but good practice)
Set oWshnetwork=CreateObject("wscript.network") 'Create the network object
oWshnetwork.AddWindowsPrinterConnection "\\myServer\myPrintershare" 'use
the AddWindowsPrinterConnection Method
'**SCRIPT END

If you would like to use a users group membership to determine what printers
a users should have installed, you could extend the script to check for
group membership. Try something like this

'**SCRIPT START
Dim oWshnetwork
Dim adSysinfo
Dim ADObj

set adsysinfo=createobject("adsysteminfo") 'create a ADSSystemInfo Object
Set oWshnetwork=CreateObject("wscript.network") 'Create a Network Object
Set ADObj=GetObject("LDAP://" & adSysinfo.UserName) 'Bind a object to the
dirctory path of the user logging on

For Each group In ADObj.groups 'Check what groups the user is a member of

Select Case group.samaccountname
' Check if the user is a member of Printergroup1 if so install printer
Case "PrinterGroup1"
oWshnetwork.AddWindowsPrinterConnection "\\myServer\Printer1"
' Check if the user is a member of Printergroup2 if so install printer
Case "PrinterGroup2"
oWshnetwork.AddWindowsPrinterConnection "\\myServer\Printer2"

End select
next
'**SCRIPT END

Good luck

Niclas Lindblom
 
Back
Top