Page 1 of 1 1
Topic Options
#198962 - 2010-07-08 04:19 PM Drive Mapping by .ini
anaftel Offline
Just in Town

Registered: 2010-07-06
Posts: 4
Loc: Guernsey, UK
I am trying to run the below code however all it seems to do is freeze the DOS window and when I force that to clost logs my PC off .. what am I doing wrong?

Thanks
Andy

 Code:
;Enumerate all group for the current user.
$groups = arrayenumgroup()
;Start the magic for each group.
For Each $group in $groups
	;Read the number of drives to be mapped for each group.
	$drives = ReadProfileString("D:\My Dropbox\Specsavers\Login Scripts\Specsavers\DriveMapping.ini", $group, "NumberOfDrives")
	;Map each drive.
	For $i = 1 to $drives
		;Read drive data from ini file.
		$drive = ReadProfileString("D:\My Dropbox\Specsavers\Login Scripts\Specsavers\DriveMapping.ini", $group, "MapDrive" + $i)
		$drive = Split($drive, ",")
		;MapDrv ($drive[0],$drive[1],$drive[2])
		Use $drive[0] + ': "' + $drive[1] + '"'
	Next
Next

Exit

;DO NOT MODIFY ANYTHING BELOW THIS LINE.
;IT IS A UDF AND IT COMES READY FOR USE.

;NAME          ARRAYENUMGROUP
;
;AUTHOR        Jens Meyer (sealeopard@usa.net)
;
;ACTION        Creates an array of groups of which the current user is a member
;   
;SYNTAX        ARRAYENUMGROUP()
;  
;PARAMETERS    none
;
;RETURNS       Array containing the group names
; 
;REMARKS       none
;
;DEPENDENCIES  none
;  
;EXAMPLE       $retcode=arrayenumgroup()
;
Function arrayenumgroup()
	Dim $retcode, $valuecounter, $currentvalue, $valuearray
		  
	$valuecounter = 0
	Do
		$currentvalue = EnumGroup($valuecounter)
		If $currentvalue <> 259 And @ERROR = 0
			ReDim preserve $valuearray[$valuecounter]
			$valuearray[$valuecounter] = $currentvalue
			$valuecounter = $valuecounter + 1
		EndIf
	Until $currentvalue = 259 Or @ERROR
		  
	$arrayenumgroup = $valuearray
EndFunction


 Code:
; Drive mappings other than primary user, group and common drives

[Authenticated Users]
NumberOfDrives=2
MapDrive1=f,perseus,exporthome\andyn
MapDrive2=i,Perseus.gg.specsavers.com,SolarisOutput

[Domain Users]
NumberOfDrives=1
MapDrive1=t,Perseus,co-data


Edited by anaftel (2010-07-08 06:14 PM)

Top
#198964 - 2010-07-08 06:43 PM Re: Drive Mapping by .ini [Re: anaftel]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Andy,

Welcome to KORG!

I'm not sure what Jens' original intent was, but the check for value "259" doesn't seem valid anymore. Try this updated version of the UDF:
 Code:
Function arrayenumgroup()
	Dim $retcode, $valuecounter, $currentvalue, $valuearray
		  
	$valuecounter = 0
	$currentvalue = EnumGroup($valuecounter)
        While Not @ERROR And $currentvalue
		ReDim preserve $valuearray[$valuecounter]
		$valuearray[$valuecounter] = $currentvalue
		$valuecounter = $valuecounter + 1
		$currentvalue = EnumGroup($valuecounter)
	Loop
		  
	$arrayenumgroup = $valuearray
EndFunction
Also, add "Break On" to the top of your script while testing, which will allow you to break the script processing without forcing a logoff. This is documented in the manual and FAQs.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#198971 - 2010-07-09 04:17 PM Re: Drive Mapping by .ini [Re: Glenn Barnas]
anaftel Offline
Just in Town

Registered: 2010-07-06
Posts: 4
Loc: Guernsey, UK
Thanks for the help that did the trick, also thanks for sending me the files from your website the other day they have been very useful

Andy

Top
#198972 - 2010-07-09 04:52 PM Re: Drive Mapping by .ini [Re: anaftel]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
No problem! Glad they were helpful. We're about 90% complete with our migration now.. of course, the two large projects we're working on right now take priority over our internal issues, so thanks for understanding.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 632 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.053 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org