I have implemented the script below to add printer connections based on a users floor but now have the need to remove printers if the user moves floors
code:
$PRTserver=sthfs2
$regkey="HKCU\Printers\Connections\,,"+$PRTserver+","+$printer ;Registry key for printer connections
$levels=ReadProfileString('@CURDIR\printers.ini','','') ;Read printers.ini string
$levels=Split($levels,Chr(10))
ReDim preserve $levels[Ubound($levels)-1]
For Each $level in $levels ;Split results
If InGroup ("@DOMAIN\"+$level)= 1 ;Check for group membership
If KeyExist($regkey) ;Check if printer already connected
? "Printer already connected"
Else
$printers=ReadProfileString('@CURDIR\printers.ini',$level,'Printers')
$printers=Split($printers,',')
For Each $printer in $printers
$nul=AddPrinterConnection("\\$PRTserver\"+$printer)
Next
EndIf
Else
EndIf
Next
INI File -------------------------------------
[Level 1 Printers]
Printers=1FLR_PRT1_HP4100_BW_A4
[Level 2 Printers]
Printers=2FLR_PRT1_SHC250_COL_A3
[Level 3 Printers]
Printers=3FLR_PRT1_HP4100_BW_A4
[Level 8 Printers]
Printers=8FLR_PRT1_HP4050_BW_A4
Basically, if a user was in 1st floor group and now moves to the 2nd floor group I want to read the INI file and remove all printer connections from the old group and remap to the new group. I only want to add printers once. I want to avoid deleting and adding printers on each login. The situation I have at the moment is if the user moves floors they end up with both floors printers.
Any ideas ?
Cheers,
Grasshopper
_________________________
Just Another Aussie on Tour !