Kdyer
(KiX Supporter)
2004-04-21 10:50 PM
ENUMINI() - Revisited

Using Lonk's version of enumINI() - Load ini-file into array

I can get the drives to map for everything except user's H: drives..

Code:

CLS
BREAK ON
DIM $rc
;$rc=SETOPTION("NoVarsInStrings","ON")
;ENUMINI(@scriptdir+"\DRIVES.INI")
;?
;?'Process complete..'
;get $

"treeview of ini-file"
$data=enumINI(@scriptdir+"\DRVMAP.ini")
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
?'"'+$grp='"'
IF INGROUP($grp)
?"member of "+$grp
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
?$drive+':' $resource
?$drive
?$resource
NEXT
ENDIF
NEXT
ELSE
$grp=$section[0]
?'"'+$grp+'"'
IF INGROUP($grp)
?"member of "+$grp
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
?$drive+':' $resource
?$drive
?$resource
NEXT
ENDIF
ENDIF
NEXT
ENDIF
??"process complete.."
GET $



INI Structure is as follows:
Code:

[DOMAIN1\MMC PDX,DOMAIN2\PDX]
H=\\RESOURCE\@userid$
R=\\APPS\APPS
S=\\RESOURCE\SHARED
[Beaverton]
F=\\REMOTE\apps
H=\\REMOTE\USERS$\+@userid
R=\\APPSERVER\apps
S=\\REMOTE\shared
T=\\RESOURCE\shared
[Marketing]
N=\\IIS\MARKET
[DOMAIN1\Info_Technology,DOMAIN2\MMC Info_Technology]
G=\\RESOURCE\IS



I have tried to use the EXECUTE to do this with no success.

Thanks,

Kent


Les
(KiX Master)
2004-04-21 11:02 PM
Re: ENUMINI() - Revisited

Well.. I can't see how execute is supposed to work on the line:
\\REMOTE\USERS$\+@userid

there are no quotes for concatenation.
'\\REMOTE\USERS$\'+@userid


Les
(KiX Master)
2004-04-21 11:05 PM
Re: ENUMINI() - Revisited

Maybe you could just leave out the +
\\REMOTE\USERS$\@userid


Kdyer
(KiX Supporter)
2004-04-21 11:46 PM
Re: ENUMINI() - Revisited

Went back through my notes and found the answers..

Code:

H=\\RESOURCE\+@userid+'$'
W=\\RESOURCE\USERS+'$\'+@userid



Thanks for your help.

Kent


Kdyer
(KiX Supporter)
2004-04-22 12:50 AM
Re: ENUMINI() - Revisited

OK.. If I comment out -
Code:

$rc=execute('$$resource='+$resource)



It works fine, but if I uncomment it, and run with the login script it shows:
Quote:


ERROR : undefined variable []!
Script: \\SERVER\NETLOGON\newscript\ENUMINI.KIX
Line : 1





Thanks,

Kent


Les
(KiX Master)
2004-04-22 01:07 AM
Re: ENUMINI() - Revisited

That would indicate you set 'explicit','on'

Kdyer
(KiX Supporter)
2004-04-22 02:56 AM
Re: ENUMINI() - Revisited

I take it with this example I cannot use that? I have been using this to clean up our login script quite significantly.

Kent


Les
(KiX Master)
2004-04-22 03:58 AM
Re: ENUMINI() - Revisited

You could of course, DIM all the vars.

Your way of using Execute() precludes 'NoVarsInStrings' too.


Kdyer
(KiX Supporter)
2004-04-22 02:25 PM
Re: ENUMINI() - Revisited

I have covered that already, but did not post until now as I was trying to get out of the office for a HALO Party last night.

Code:

DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP(''+$grp+'')
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
$grp=$section[0]
IF INGROUP(''+$grp+'')
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
ENDIF



Is there a better or different way to do the EXECUTE(), so that I can get the hidden mappings?

Kent


Kdyer
(KiX Supporter)
2004-04-22 04:34 PM
Re: ENUMINI() - Revisited

OK.. figured part of it out..

Changed -
Code:

$rc=execute('$$resource='+$resource)



To -
Code:

$rc=execute('$resource='+$resource)



However, it does not map the H: drive proper.

Kent


Kdyer
(KiX Supporter)
2004-04-22 05:24 PM
Re: ENUMINI() - Revisited

OK.. Here is the updated script - thanks Les for pointing me in the right direction..

Code:

DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
$rc=SETOPTION('NoVarsInStrings','Off')
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP($grp)
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
IF INGROUP($section[0])
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
$rc=SETOPTION('NoVarsInStrings','On')
ENDIF



Kent


Kdyer
(KiX Supporter)
2004-05-07 06:07 PM
Re: ENUMINI() - Revisited

We seem to be having a problem with groups preceded with an underscore "_".

For example -
Code:

[DOMAINA\_IT Systems Engineering]
N=\\DevServ\groups\Technology Services\Systems Engineering
I=\\APPS\INSTALLS
J=\\MAIN\SHARE+'$$'


It appears to bomb on the "header" for this section of the file.

Thanks,

Kent


Kdyer
(KiX Supporter)
2004-05-08 01:08 AM
Re: ENUMINI() - Revisited

OK.. Here is what works.. Now, that we sorted out the "_" deal.

Note: The check for '$$' is really only needed when an Admin share is used and then it is executed.

Code:

; -- PURPOSE: Map user drives from an INI file and into an array
FUNCTION DRVMAP
DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
$rc=SETOPTION('NoVarsInStrings','Off')
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP($grp)
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
IF INSTR($resource,'$$')
$rc=execute('$$resource='+$resource)
ENDIF
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
IF INGROUP($section[0])
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
IF INSTR($resource,'$$')
$rc=execute('$$resource='+$resource)
ENDIF
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
$rc=SETOPTION('NoVarsInStrings','On')
ENDIF
ENDFUNCTION



Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-08 01:22 AM
Re: ENUMINI() - Revisited

eh, so you say having string with macros in it gets executed automatically?

Kdyer
(KiX Supporter)
2004-05-08 04:16 AM
Re: ENUMINI() - Revisited

I think you are right.. It works well now, but I think it can be distilled down more - for a good Golf score.

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-08 06:59 PM
Re: ENUMINI() - Revisited

so, if your macros and vars work from the input, then executing on the admin share is not needed either.
but here we go...
ruud has made it so, that vars in strings does not include macros.
thus, you should be safe but leaving no vars in strings on.


Kdyer
(KiX Supporter)
2004-05-09 07:45 AM
Re: ENUMINI() - Revisited

I guess we need to re-visit this as the only way to work this is to run the NOVARSINSTRING OFF and then ON again. If left as ON, I get an error on LINE 1 [] as it triess to break up the groups in each header of the INI file.

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-09 10:16 AM
Re: ENUMINI() - Revisited

well, doesn't that sound a bit buggy

Kdyer
(KiX Supporter)
2004-05-09 05:19 PM
Re: ENUMINI() - Revisited

So the question still remains..

Can it be done with NOVARSINSTRINGS ON?
Code:

[DOMAINA\ACCTG,DOMAINB\ACCOUNTING]
G=\\SERVER\ACCTG
S=\\APPSERVER\APPS
[DOMAINA\HR]
G=\\SERVER\HR
S=APPSERVER\SHARED


So, the point being if you have one group or many groups that need to be split up, it does not seem to matter.

Thanks,

Kent


kholm
(Korg Regular)
2004-05-10 02:37 AM
Re: ENUMINI() - Revisited

There could be some matters arround Execute() and NoVarsInStrings.

Could you try the following function, whitch turns on VarsInStrings before Execute() and then restores it to its previous state.

Code:

Function DRVMAP()
Dim $rc,$data,$section,$grp,$i,$drive,$resource,$NoVarsInStrings
$data = EnumINI(@LDrive + '\NewScript\DRVMAP.ini')
If Not @Error
For Each $section In $data
$grp = Split($section[0],',')
If InGroup($grp)
For $i = 1 To UBound($section)
$drive = $section[$i][0] + ':'
$resource = $section[$i][1]
$NoVarsInStrings = SetOption('NoVarsInStrings','Off')
$rc = Execute('$$resource=$resource')
$rc = SetOption('NoVarsInStrings',$NoVarsInStrings) ; Set NoVarsInStrings to previous state
Use $drive $resource
Next
EndIf
Next
EndIf
EndFunction



-Erik


Kdyer
(KiX Supporter)
2004-05-10 08:16 AM
Re: ENUMINI() - Revisited

Cool.. I will dig into this in the morning.

I will let you know what the results are.

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-10 11:12 AM
Re: ENUMINI() - Revisited

I still say, there is no need to pull it off or on.
it the code is written properly, in most cases it does not matter which setting is on.


Kdyer
(KiX Supporter)
2004-05-10 02:13 PM
Re: ENUMINI() - Revisited

Lonk,

It is your code that I am using. Maybe it is right. I started this, but your re-wrote the ENUMINI() UDF and I took off with your version knowing it is better than mine. Maybe it is the DRVMAP() function that was started and Kholm distilled down. I am willing to take any suggestions.

Thanks,

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-10 02:23 PM
Re: ENUMINI() - Revisited

eh?
I thought this was all about the drvmap()?
there is no discuss in this thread about problems with enuming the ini, is there?

and the code:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=83541&page=28&view=collapsed&sb=3&o=all&fpart=1
does not include any switches for novarsinstrings, nor there is any executions.
afaik.

so, the wisdom, of this drvMapper is the thing we are discussing, right?
facing problems in my code, I would like to hear but haven't herd so I must keep my mind that this drvmapper has a problem.


Kdyer
(KiX Supporter)
2004-05-10 02:29 PM
Re: ENUMINI() - Revisited

If memory serves me correct, this was started as ENUMINI() - but, was really "another drive mapper." You re-wrote it to be simply an INI parser. I wanted to use your version of the INI parser with the ability to map drives through an INI database.

Kent


LonkeroAdministrator
(KiX Master Guru)
2004-05-10 03:27 PM
Re: ENUMINI() - Revisited

yup.
so, back to the actual problem at hand.
novarsinstrings and execution, neither have any problems with hidden shares.
only where execute comes in the game and might require setting the novars switch is when you have macros etc in the path.


Kdyer
(KiX Supporter)
2004-05-10 07:57 PM
Re: ENUMINI() - Revisited

I think we need some more work on this..

Kent


Sealeopard
(KiX Master)
2004-05-11 04:25 AM
Re: ENUMINI() - Revisited

Take a look at this MapDrive() UDF: MapDrive() - Maps a UNC name to a specific driveletter .

It does support macros in the share name or label and still adheres to the NoVarsInStrings=ON mantra, which, BTW, does not affect macros anyway.


LonkeroAdministrator
(KiX Master Guru)
2004-05-11 04:32 AM
Re: ENUMINI() - Revisited

nor admin shares.