#34463 - 2002-12-11 07:29 PM
Removing Printers using INI file
|
Grasshopper
Fresh Scripter
Registered: 2002-11-29
Posts: 15
Loc: London, UK
|
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 !
|
|
Top
|
|
|
|
#34465 - 2002-12-11 07:38 PM
Re: Removing Printers using INI file
|
Grasshopper
Fresh Scripter
Registered: 2002-11-29
Posts: 15
Loc: London, UK
|
This looks OK but how can I extend it to remove printers based on sections within the INI file ?
eg. Bob moves from floor 1 to 2, has 1st floor printers currently. Remove Bob from Level 1 Group, add him to Level 2 group. Bob logs in, script removes level 1 printers and adds level 2 printers based on one INI file.
I have a feeling I might have to create another group ????????
_________________________
Just Another Aussie on Tour !
|
|
Top
|
|
|
|
#34467 - 2002-12-11 07:55 PM
Re: Removing Printers using INI file
|
Grasshopper
Fresh Scripter
Registered: 2002-11-29
Posts: 15
Loc: London, UK
|
Sorry Jens, I don't quite understand your entire script, I get parts of it. The section names in my INI file are also the NT group names of which the user must be a part of to map the printers within each section. What will I need to modify in your script to unmap the printers without changing the section names of the INI file ?
_________________________
Just Another Aussie on Tour !
|
|
Top
|
|
|
|
#34468 - 2002-12-11 08:22 PM
Re: Removing Printers using INI file
|
Grasshopper
Fresh Scripter
Registered: 2002-11-29
Posts: 15
Loc: London, UK
|
Also, how easy would it be to remove a printer if the user is in the correct group though the printer no longer exists based on my current INI format ?
_________________________
Just Another Aussie on Tour !
|
|
Top
|
|
|
|
#34472 - 2002-12-11 08:49 PM
Re: Removing Printers using INI file
|
Grasshopper
Fresh Scripter
Registered: 2002-11-29
Posts: 15
Loc: London, UK
|
It seems you have a better idea of what i need to do than I do ! Why did you have to make it seem so simple !! I can't believe I couldn't think of a simple thing like that. I guess I was getting too caught up in it all.
Thanks.
Grasshopper
_________________________
Just Another Aussie on Tour !
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|