#24908 - 2002-07-11 10:50 PM
Macro problem using INI file.. Please help!!!
|
KixStuck
Fresh Scripter
Registered: 2002-07-11
Posts: 8
|
I am creating a script that will map drives for my users. Problem exists when I have to use a macro in the INI file and in the script trying pipe the result to a variable. It interprets the result has a string, which is understandable. I need to find out how to get Kixtart to recognize macro embedded in the string.
Sample Code:
$GrpName = readprofilestring ("@lserver\netlogon\kix\ini\groups.ini", 3, "group") $DrvLtr = readprofilestring ("@lserver\netlogon\kix\ini\groups.ini", 3, "drive") $Share = readprofilestring ("@lserver\netlogon\kix\ini\groups.ini", 3, "share")
at (13,5) "Executing:" If ingroup("$GrpName") at (13,20) "Mapping $DrvLtr to $Share" Messagebox ($Share,"Show Share",) use $DrvLtr /delete use $DrvLtr $Share sleep 2 endif
Sample of the INI file:
[3] Group="network group" Drive=W: Share=\\is\netdata\users\@userid\lnotes
Thanks in advance for any assistance.
|
|
Top
|
|
|
|
#24910 - 2002-07-11 11:23 PM
Re: Macro problem using INI file.. Please help!!!
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Welcome to the board.
It is possible by using the Execute command. Our version is
code:
$grpname = ReadProfileString ("@lserver\netlogon\kix\ini\groups.ini", "3", "group") $drvltr = ReadProfileString ("@lserver\netlogon\kix\ini\groups.ini", "3", "drive") $share = ReadProfileString ("@lserver\netlogon\kix\ini\groups.ini", "3", "share") $nul = Execute('$dummy="$share"') $share = $dummy
At (13,5) "Executing:" IF (InGroup("$GrpName") <> 0) At (13,20) "Mapping $DrvLtr to $Share" $nul=MessageBox ($share,"Show Share") USE $drvltr /delete /persistent USE $drvltr $share ENDIF
FYI: IF/ENDIF win combination with Execute will not work. IF/ENDIF creates it in his own environment block. So don't use structures like this
code:
$share = ReadProfileString ("@lserver\netlogon\kix\ini\groups.ini", "3", "share") IF Execute('$dummy="$share"') ENDIF $share = $dummy
the result isn't the same.
greetings.
|
|
Top
|
|
|
|
#24911 - 2002-07-11 11:28 PM
Re: Macro problem using INI file.. Please help!!!
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
As MCA stated:
Use the Execute() function to resolve the contents of @userid
You read the share from the ini-file, as you have done:
code:
$Share = readprofilestring ("@lserver\netlogon\kix\ini\groups.ini", 3, "share")
Add the following line just after this, to 'execute' the macro in the string:
code:
$RC = Execute('$$Share="$Share"')
If you are logged in as user: jaemi
Then $Share will contain: \\is\netdata\users\@userid\lnotes Before the Execute()
And \\is\netdata\users\jaemi\lnotes After the Execute()
-Erik
ps.
MCA, Your execute statement should look like this: $nul = Execute('$$dummy="$share"') [ 11 July 2002, 23:36: Message edited by: kholm ]
|
|
Top
|
|
|
|
#24913 - 2002-07-11 11:54 PM
Re: Macro problem using INI file.. Please help!!!
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear kholm,
Indeed your version is also possible, but during testing with IF/ENDIF structure we introduce the additional variable. greetings.
|
|
Top
|
|
|
|
#24914 - 2002-07-11 11:59 PM
Re: Macro problem using INI file.. Please help!!!
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
jaemi
Your question was answered here. Please do not cross post. I have deleted the topic from SCRIPTS forum as all answers are here already.
http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=003598
|
|
Top
|
|
|
|
#24915 - 2002-07-12 12:43 AM
Re: Macro problem using INI file.. Please help!!!
|
KixStuck
Fresh Scripter
Registered: 2002-07-11
Posts: 8
|
Thanks everyone!!! It works... You guys are a life saver (and not to mention time saver).
Thanks again.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1172 anonymous users online.
|
|
|