Thank you for the response. This looks like it might just do what I want it to do. I do have two questions.
First, this will work for Windows 2000 as well as Windows XP, right (I don't see why it wouldn't, but one solution I tried was supposed to work for both but didn't work for Windows 2000)?
Second, what modifications would I have to make to the above if I wanted to just add the printers rather than set a default printer (in some cases I'm connecting 4 or 5 printers)? I had originally wanted to set the default printer, but there are some users that have local printers and I don't want to override their default printer settings by assigning them a network printer as their default printer. Since the first printer that gets added gets set as the default, then just by adding the printer I want as the default printer before I add the other network printers, I should be OK.
I'm currently implementing a very convoluted method of searching text files that isn't working out so well so this script will be a very welcome change.
Thank you,
Daniel
Main Topics
Browse All Topics





by: BlueDevilFanPosted on 2005-01-07 at 03:24:50ID: 12981810
Hi, Daniel.
ork") er "PrinterName"
ter.ADsPat h) Then
Here's a script (VBScript) that should handle this for you. It tests to see if a computer is a member of a given group. If it is, then it sets the default printer, otherwise it does nothing. I put this together quickly and have not tested it yet (I'm not in a position to at the moment).
'Script Begins Here
Dim objNetwork, objComputer, strDomain, strComputerName
strDomain = "DomainName"
Set objNetwork = CreateObject("Wscript.Netw
strComputerName = objNetwork.ComputerName
Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputerName & ",computer")
If IsGroupMember(strDomain, "MyGroup") Then
objNetwork.SetDefaultPrint
End If
Set objNetwork = Nothing
Set objComputer = Nothing
Wscript.Quit
Function IsGroupMember(strDomain, strGroup)
Dim objGroup
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
If objGroup.IsMember(objCompu
IsGroupMember = True
Else
IsGroupMember = False
End If
Set objGroup = Nothing
End Function