World: r3wp
[Core] Discuss core issues
older newer | first last |
Graham 14-Jul-2006 [5061x2] | using the win32 api |
hmm. Doesn't work. | |
BrianH 14-Jul-2006 [5063] | Graham, there are two good reasons for that: Security and portability. Some platforms have one environment, some have per-process, some have global and per-user (like Windows) - which environment do you want to set? As for security, if you set any variable other than per-process it can affect the behavior of other programs, an ability that should be restricted in a sandboxed environment. You should check out command line apps that you can call to set the various environments on your platform. If the REBOL process doesn't have call because of security restrictions, it shouldn't be able to set environment variables anyways. |
Volker 14-Jul-2006 [5064] | run is available in ios. Somewhere i read in windows one can type a filename in shell, like text.txt, and windows launches the accosiated application. If that works, maybe with 'call too? |
Graham 14-Jul-2006 [5065] | I think the lack of 'run in other than IOS is some type of oversight. |
Volker 14-Jul-2006 [5066] | I agree |
Graham 14-Jul-2006 [5067] | I wonder why using the windows 32 api, I still can't set the user environment variables |
Volker 14-Jul-2006 [5068] | In linux they are copied for each process, not shared AFAIK. MAybe windows does the same? |
Gregg 15-Jul-2006 [5069] | ; Does this work for you Graham? REBOL [] ; GET-ENV is a standard REBOL function now ; environment variable APIs ; msvcrt.dll ; getenv _putenv _environ ; char *getenv( const char *varname ); ; int _putenv( const char *envstring ); lib: load/library %msvcrt.dll get-env: make routine! [ varname [string!] return: [string!] ] lib "getenv" put-env: make routine! [ env-string [string!] return: [integer!] ] lib "_putenv" remove-env-var: func [name [string!]] [put-env join name "="] env-var-exists?: func [name [string!]] [ either "^@" = get-env name [false][true] ] tz-set: make routine! [ return: [integer!] ] lib "_tzset" print get-env "path" print get-env "lib" print get-env "temp" print get-env "test" if 0 <> put-env "test=blah" [ print "error writing environment variable" ] print get-env "test" remove-env-var "test" print mold get-env "test" print get-env "TZ" tz-set free lib halt |
Graham 15-Jul-2006 [5070] | No, it doesn't. It appears to .. but as soon as you quit the rebol session and see if the env variable is still set, it's not. |
BrianH 16-Jul-2006 [5071] | What you are doing there is setting the per-process environment. To set any of the other environments you need some other, somewhat more complex APIs. Or some much more simple command line apps. |
Graham 16-Jul-2006 [5072] | I guess that's why we have get-env and not set-env |
BrianH 18-Jul-2006 [5073x2] | I have a few command line apps that do the job, but the best one I've found I got from a web site that isn't there any more. If you want it PM me and I will email it to you. Otherwise, try setx.exe from the Windows Resource Kit - it can do all sorts of stuff. |
There are 4 environments on Windows (aside from the per-process ones), the system, user, default user and volatile environments. The setenv.exe I found can set any of these 4, the setx.exe in the Resource Kit can set the system and user environments. | |
Graham 18-Jul-2006 [5075] | I'm only looking at present to set the current user environment |
BrianH 18-Jul-2006 [5076x2] | Do you mean the current user's initial environment, or something less lasting? |
Or do you mean the REBOL process' environment that is inherited by the subprocesses started by CALL (assuming that CALL internally passes along the current environment to its subprocesses)? Or do you mean the environment of the parent process? Every started process is passed an environment, usually a copy of the parent environment (sometimes with some modifications). On Windows (NT kernel, not 9x), the initial environment is a combination of variables associated with the system (or machine), the user and volatile values, in that order. The initial values of these variables are constructed from data in the registry. Once these variables are constructed and compiled into an environment, this environment is passed to a process. Changes to the environment of that process (with getenv and setenv) don't affect the environment of the parent processes, and certainly don't affect the global values. To change the initial environment variables, you need to change them in their original registry entries. You can either do that directly or through using external applications. Keep in mind that changes to these initial values won't affect your current environment, or those of any running processes, as those environments are already set and can only be changed internally. | |
Graham 18-Jul-2006 [5078x2] | I want to change the user environment strings that othewise I have to do in the control panel -> system -> advanced |
so that they remain changed when I next login | |
BrianH 18-Jul-2006 [5080] | Do you need to support Win9x, or just WinNT derivatives like 2000, XP and 2003? |
Graham 18-Jul-2006 [5081x2] | Just Win32 |
and Win64 | |
BrianH 18-Jul-2006 [5083] | Windows 95 is Win32 as well, but its environment handling is completely different. My question still stands :) |
Graham 18-Jul-2006 [5084] | Ok, 2000, XP, 2003 |
BrianH 18-Jul-2006 [5085x4] | Then it's registry values you need to change. Give me a moment and I'll figure out which ones. |
Environment variables are based on values of the following registry keys, for each type: - Local machine: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment - Current user: \Environment - Default user: HKEY_USERS\.DEFAULT\Environment - Volatile (probably should be treated as readonly): HKCU\Volatile Environment | |
Sorry, mistype... - Current user: HKCU\Environment | |
You can check in regedit for your current values. Remember to use REG_EXPAND_SZ values if you want references to other environment variables to be expanded, but keep in mind that these are evaluated in one pass for each category, and that local machine is evaluated before current user. A value can't make references to other variables in its own category, just references to values in other categories that are evaluated earlier. | |
Graham 18-Jul-2006 [5089x3] | found them! |
My Computer\HKEY_CURRENT\Environment | |
and else where :( | |
BrianH 18-Jul-2006 [5092] | The environments you are likely interested in are in the locations I specified. If you want to make changes to all users' local environments, look at the other keys under HKEY_USERS. The .DEFAULT key is what gets copied to a new user's local registry when that user is created. |
Graham 18-Jul-2006 [5093] | Ok. |
BrianH 18-Jul-2006 [5094x2] | Obviously you will need admin priviledges for any keys not under HKCU. |
HKEY_CLASSES_ROOT is one of those fake, mirror keys. | |
Sunanda 18-Jul-2006 [5096] | . (apologies for the dot, but the web shows this group has failed to sync on my machine) |
Louis 26-Jul-2006 [5097x2] | Hi everyone, I am presently in Indonesia. I can send email to myself, but when I try to send email to other I get the following error message: ** User Error: Server error: tcp 550-(LATURK-WS-2) [61.94.196.24] is currently not permitted to relay through Is this a problem I can correct in the script? If yes, how? |
I am able to email using Eudora just fine. | |
Graham 26-Jul-2006 [5099x5] | nothing to do with your script |
hmm. | |
maybe you need to authenticate first before sending mail. | |
So, use rebol to read your mail first and then try sending. | |
since you're not getting a smtp authentication error. | |
Louis 26-Jul-2006 [5104x2] | Ok, I'll try that and get back with the results. |
That fixed it. Thank you so much, Graham! | |
Henrik 26-Jul-2006 [5106x2] | how does one avoid that variables listed in a block in an object become global in this instance: >> unset [a b c] >> y: make object! [a: [b c d] set a [1 2 3]] >> a ** Script Error: a has no value ** Near: a >> b == 1 >> c == 2 >> d == 3 These give the same result: >> y: make object! [a: [b c d] set bind a self [1 2 3]] >> y: make object! [a: [b c d] set bind/copy a self [1 2 3]] >> y: make object! [a: copy [b c d] set a [1 2 3]] >> y: make object! [a: bind [b c d] self set a [1 2 3]] |
hm... seem to be the old "how to add new variables to an existing object" problem. looks like I'll have to find a different approach... | |
Ladislav 27-Jul-2006 [5108] | do you know this one? d: [a b c] d: use d reduce [d] set d [1 2 3] |
Henrik 27-Jul-2006 [5109] | I guess I do now :-) |
Ladislav 27-Jul-2006 [5110] | suggested reading : http://www.fm.tul.cz/~ladislav/rebol/contexts.html ;-) |
older newer | first last |