Hi Shanee


The script works perfectly, but now there is only one problem:

I have 2 printers in the same location, and the teachers group
are member of the students group, and should therefor have both
printers installed, no problem here, but the students should not
have the printer Xerox1 installed so they dont get confused when
printing to a printer they dont have print rights to, how do i
resolve this.

I was wondering if it was possible to integrate in your script, to define and check for group membership like the section for Names and Shares, like this:

Group = students,teachers


printer.ini
[00:16:B9:52:AF:BF]
Location = Preparation
Group = students
Names = HP LaserJet 1320nw - Support,Xerox WorkCentre 7345
Shares = LaserJet1,Xerox1


Kind regards
roundup



Working script:
 Code:
$location = ReadProfileString ($LogonServer + "\NETLOGON\printer.ini", $mac, "Location")
$group = ReadProfileString ($LogonServer + "\NETLOGON\printer.ini", $mac, "Group")
$names = ReadProfileString ($LogonServer + "\NETLOGON\printer.ini", $mac, "Names")
$shares = ReadProfileString ($LogonServer + "\NETLOGON\printer.ini", $mac, "Shares")

If InStr($shares,",")
   $names = Split($names,",")
   $shares = Split($shares,",")
   If UBound($names) <> UBound($shares)
      $null = MessageBox("Der er uoverensstemmelse mellem Names og Shares. Kontroller printer.ini filen under sektionen : "+$mac,0)
   Else
      $sharenum = 0
      For Each $share in $shares
         $name = $names[$sharenum]
         If InGroup($group)
            If AddPrinterConnection("\\" + $printserver + "\" + $share) = 0
               If $sharenum = UBound($shares)
                  $null = SetDefaultPrinter("\\" + $printserver + "\" + $name)

               EndIf
            Else
               $null = MessageBox("2 Der er et problem med at etablerer forbindelse til : "+$share,"Printer fejl",0)
            EndIf
         EndIf
         $sharenum = $sharenum+1
      Next
   EndIf
Else
   If InGroup($group)
      If AddPrinterConnection("\\" + $printserver + "\" + $shares) = 0
         $null = SetDefaultPrinter("\\" + $printserver + "\" + $names)         
      Else
         $null = MessageBox("2 Der er et problem med at etablerer forbindelse til : "+$shares,"Printer fejl",0)

      EndIf
   EndIf
EndIf


Edited by Mart (2010-11-08 02:27 PM)
Edit Reason: Added code tags. Please use code tags when posting code.