Page 1 of 1 1
Topic Options
#79466 - 2003-01-31 05:42 PM 4.12 & 4.20 SETM bug
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Since 4.12, SETM updates the USER environment instead of the SYSTEM environment.

Test code:
code:
? "@KIX"
set "TEST1=one"
setl "TEST2=two"
setm "TEST3=three"
shell "cmd /c set > kix.log"

Running this with 4.01, I have TEST1 in the USER environment, TEST2 defined in the running kix environment (as evidenced by the contents of the kix.log file), and TEST3 in the GLOBAL/SYSTEM environment.

Running this with 4.12 or 4.20rc2 results in both TEST1 and TEST3 being defined in the USER environment.

This is confirmed by looking at the My Computer/Properties/Advanced/Environment utility as well as examining the registry keys.

I've run the above simple test on 2K Pro, 2K Server, and XP Pro.

I have adapted my script to directly write the values to the registry, but the user must log off & on for them to take effect. The SETM command uses a notification function to alert applications that the environment definition has changed - something that direct registry updates won't do. My workaround uses SETM to unset a fake value so the notification occurs.

code:
 
Function fSETM( $EDEF )
SETM("_My_JuNk_=T") ; define fake varname
$ENVKEY = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$aryENVARGS = Split($EDEF, "=", 2)
$fnSETM = WriteValue($ENVKEY, $aryENVARGS[0], $aryENVARGS[1], "REG_EXPAND_SZ")
SETM("_My_JuNk_=") ; remove fake varname, result is a notification to reread the env
EndFunction

fsetm("TEST4=four")

This now properly sets a system environment.

Glenn

[ 31. January 2003, 17:59: Message edited by: Glenn Barnas ]
_________________________
Actually I am a Rocket Scientist! \:D

Top
#79467 - 2003-01-31 05:50 PM Re: 4.12 & 4.20 SETM bug
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
What type of account is experiencing this problem? By default, only local administrative accounts can write to HKLM. Thus, I would not be surprised that a regular user cannot use SETM as it woudl require write access to HKLM.
_________________________
There are two types of vessels, submarines and targets.

Top
#79468 - 2003-01-31 06:27 PM Re: 4.12 & 4.20 SETM bug
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
man, I've forgotten this...
there was a problem before IIRC that if there was not the var before in system environment, it was always set in users... this seems a little different...

well, I'm running on w2k sp3 and I can confirm this.

the actual problem is that the last call to setm gets written to users own environment.

tested with:
code:
setm "something=stupid"
setm "some=else"
setm "null=value"

some and something came to system but null was written to users own.

good call glenn!

[ 31. January 2003, 18:28: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#79469 - 2003-01-31 06:30 PM Re: 4.12 & 4.20 SETM bug
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
On my workstation at work - 2K pro - my account is a domain admin, and the local admin group contains DOMAINXX\domain admins group. Same configuration on my XP Pro workstation at home.

When I log into servers at work, its my domain account, also has domain admins in the local admins group. We aren't permitted to use the "administrator" account once server builds are complete.

At home, I have used the local admin account on the servers, both the A-D master and the two member servers.

Regardless of the account used (admin vs. domain admin) the result is the same.

Just to confirm, I copied the sample script to my test server here in my office and logged in as "administrator". I opened a command prompt and ran the kix script using v4.12. TEST1 and TEST3 were again placed into the USER environment.

I removed the environment vars, and reran the test using the 4.20rc2 release. Again, only USER variables were created.

This is a change in behavour between 4.01 and the later releases. Run the code for yourself and see what happens.

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

Top
#79470 - 2003-01-31 06:32 PM Re: 4.12 & 4.20 SETM bug
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
glenn, I would also ask you to run that code of mine to confirm the theory.

thanks.
_________________________
!

download KiXnet

Top
#79471 - 2003-01-31 06:36 PM Re: 4.12 & 4.20 SETM bug
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Lonkero -

I haven't seen that behavior, actually. In my server customize script, I set 3 system vars, but at 3 times during the process - not one after another. None of them are written properly to the system environment.

In fact, because my script is designed to be run multiple times (for updates as well as fresh installs), it tests for the presence of .KIX in the PATHEXT var, and our tools dir in the PATH - updating the var only if it doesn't already contain the required value. So - there's a fair amount of logic around two of the SETM commands, and other intervening code between each of the code groups the perform the SETM calls.

At least I know now that I'm not crazy [Eek!]

I'll play a little more with the multiple SETMs here and see what happens.

Thanks,

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

Top
#79472 - 2003-01-31 06:47 PM Re: 4.12 & 4.20 SETM bug
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
That's it..

When I replaced the SETM "TEST3=three" line in my sample script with
code:
setm("TEST3a=three_A")
setm("TEST3b=three_B")
setm("TEST3c=three_C")

TEST3a and TEST3b were both written to the SYSTEM env, while TEST3c was written to the USER env.

I'll post a snippet of the code from my customization script..

code:
 
;===============================================================================
; define the system command prompt to include the server name
SETM("PROMPT=%COMPUTERNAME% - $P$G")
" Set Command-line Prompt" ?

;===============================================================================
; add the tools dir to the path if it isn't there already
If instr(%PATH%, "\usr\local\bin") = 0
SETM("PATH=%SYSTEMDRIVE%\usr\local\bin;%PATH%")
" Updated PATH" ?
EndIf

... about 60 more lines of code ...

;===============================================================================
; add .KIX to the PATHEXT if it isn't there already - this permits .KIX files
; to be run directly from a command-line
If instr(%PATHEXT%, ".KIX") = 0
SETM("PATHEXT=%PATHEXT%;.KIX")
EndIf
" Added .KIX to PATHEXT" ?

Finally - sure enough - If I change the script to:
code:
setm("TEST3a=three_A")
"Message 1" ?
setm("TEST3b=three_B")
"Message 2" ?
setm("TEST3c=three_C")
"Message 3" ?

all three are written to the USER env.

Hope this helps..

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

Top
#79473 - 2003-02-03 09:43 AM Re: 4.12 & 4.20 SETM bug
Anonymous
Unregistered


Thanks for the report.

This is indeed a regression, and it will be fixed in the final build of 4.20.

Kind regards,

Ruud

Top
Page 1 of 1 1


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

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.055 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.