#118420 - 2004-04-21 10:50 PM
ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118423 - 2004-04-21 11:46 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Went back through my notes and found the answers..
Code:
H=\\RESOURCE\+@userid+'$' W=\\RESOURCE\USERS+'$\'+@userid
Thanks for your help.
Kent
|
Top
|
|
|
|
#118424 - 2004-04-22 12:50 AM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118426 - 2004-04-22 02:56 AM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I take it with this example I cannot use that? I have been using this to clean up our login script quite significantly.
Kent
|
Top
|
|
|
|
#118428 - 2004-04-22 02:25 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118429 - 2004-04-22 04:34 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118430 - 2004-04-22 05:24 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118431 - 2004-05-07 06:07 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118432 - 2004-05-08 01:08 AM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118434 - 2004-05-08 04:16 AM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I think you are right.. It works well now, but I think it can be distilled down more - for a good Golf score.
Kent
|
Top
|
|
|
|
#118436 - 2004-05-09 07:45 AM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118438 - 2004-05-09 05:19 PM
Re: ENUMINI() - Revisited
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
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
|
Top
|
|
|
|
#118439 - 2004-05-10 02:37 AM
Re: ENUMINI() - Revisited
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
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
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|