Notifications
Clear all

[Closed] Losing EnvVariable when closing 3dsmax

Hi,

I have a little problem with environment variables.

i set my envVariable like this : 
 [b]systemTools.setEnvVariable "MyVar" "HelloWorld"[/b]
then i can get it back with this line : 
 [b]systemTools.getEnvVariable "MyVar"[/b]
it returns me 
  [b]"HelloWorld"[/b]

If i restart Max and 
 [b]systemTools.getEnvVariable "MyVar"[/b]
i get 
 [b]Undefined[/b]

The purpose of an env variable is to stay on the computer independetly of the max session , is'nt it ?

I am with 3dsmax 2010 and windows vista. maybe that matters ?
5 Replies

As a workaround, you could declare and assign a global variable (or read it from an INI file) in a script and put it in your scripts/startup folder.
I have not idea why the envVariable is not working, though…

cheers

M

Probably some Windows UAC security “feature”?

What i want to do is to keep a path into a environment variable.

I have a tool where you must choose a texture, i want to save the last path that the user selected so that the next time he uses the tool (even after restarting max) he will not be forced to go through all the folders again.

But it seems that i lose any trace of my env variable after restarting 3dsmax…

I’d just put a .ini file into the #plugcfg folder, that’s the right way and it’s very easy with maxscript functions.

from VC help, its for c++, but applies here also:

Calling SetEnvironmentVariable has no effect on the system environment variables. The user can add or modify system environment variables using the Control Panel. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key…

guruware