cmax
(Fresh Scripter)
2009-07-28 04:10 PM
Map drives and printer by group memberships not working correctly

Greetings
I'm new to scripts and don't understand why the example below maps different items depending on its location in the script.

 Code:
Use s: /delete /persistent
Use p: /delete /persistent
Use o: /delete /persistent

If InGroup("all staff") >0
	Use s: "\\myserver\staffarea"
	ADDPRINTERCONNECTION ("\\myserver\staffprinter") 
Endif

If InGroup("all pupils") >0
	Use p: "\\myserver\pupilarea"
	ADDPRINTERCONNECTION ("\\myserver\pupilprinter") 
Endif

If InGroup("office") >0
	Use o: "\\myserver\officearea"
	ADDPRINTERCONNECTION ("\\myserver\officeprinter") 
Endif


If a user belongs to both "all staff" & "office" group they don't get both sets of mappings.
Is this easy to correct?

Is there a way that when logging onto the pc I can process/check all the commands/errors that the script runs?

Many thanks

Craig


Bryce
(KiX Supporter)
2009-07-28 05:30 PM
Re: Map drives and printer by group memberships not working correctly

You can run the script in debug mode

 Code:
kix32 <script> /d


this will let you run things 1 line at a time and see what is going on.


Mart
(KiX Supporter)
2009-07-28 07:58 PM
Re: Map drives and printer by group memberships not working correctly

Bryce,

Did you post some funky stuff? My entire screen is messed up and the Reply, Quote, etc... options are gone.

CMAX,

Please use the code tags when posting code. I added them for you this time.

Some tips for your script:
- The >0 after each Ingroup is not needed.
- To be sure mapping the drive works you could delete it before creating it.
- You could put in some debug lines that show stuff on the screen. Like "User is in All Pupils group", "User is in Office group", etc...


cmax
(Fresh Scripter)
2009-07-29 02:49 PM
Re: Map drives and printer by group memberships not working correctly

Thanks for the quick reply.
Debug "on" is proving to be a big help.
Cheers


cmax
(Fresh Scripter)
2009-07-31 12:05 AM
Re: Map drives and printer by group memberships not working correctly

Thank you for the replies.

Strange, when I posted my reply to the 1st response there were no other posts yet.

My 1st script is coming along quite well thanks. I'm using the manual and website to help simplify my script. Would you be able to point me in the right direction for the any of the following:

(ver 4.53)
1) Can Enumgroup be used to simply display all the groups a user is a member of in Win2003 XP enviroment?

2) Can I use diferent arrays to group printer mappings in then use the array to map those printers to user with IF InGroup?
eg - $PupilMapping="\\server\printer1","\\server\printer2"
then - If InGroup("pupils") map all printers in $PupilMapping

Thank you for your support.


Bryce
(KiX Supporter)
2009-07-31 04:54 AM
Re: Map drives and printer by group memberships not working correctly

for #2, take a look at the "for each" command

Mart
(KiX Supporter)
2009-07-31 08:56 AM
Re: Map drives and printer by group memberships not working correctly

 Originally Posted By: cmax

Strange, when I posted my reply to the 1st response there were no other posts yet.
....


That was because Bryce posted something that was interpreted as HTML by the board and that accidently messed up the thread. All is fixed by Richard H now.

 Originally Posted By: cmax

....
1) Can Enumgroup be used to simply display all the groups a user is a member of in Win2003 XP enviroment?
....

Yes.


cmax
(Fresh Scripter)
2009-07-31 12:37 PM
Re: Map drives and printer by group memberships not working correctly

Enumgroup working well - thank you

 Code:
 

$PupilMappings = "\\server\share1","\\server\share2"

For Each $Element in $PupilMappings
	Use o: $Element
	Use z: $Element



Is this the best method for grouping map drives to use in script when user is a member of group map all drive in the array?

Cheers