I'm trying to write a simple app that will change/set window's environment variables. Something like window's "Setx" command.
If there a command to do this?
In running under Windows 7 if that matters.
Thanks
Changing Windows Environmental Variables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 239
- Joined: Tue Jun 30, 2009 11:15 pm
Re: Changing Windows Environmental Variables
Hi Alric.
If you are just changing the environment variables for your applications process only (IE. Internet Explorer and other Applications keep the standard ones issued by Windows) then you can simply do the following:
If however you want to change it on a global scale then you can look in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment for a list of environment variables Windows creates at boot up. This area is present as far back as Windows NT 4.0 I believe, you would need to find out yourself for earlier versions, so compatibility will be ensured.
BUT!!!
Be warned this area is dangerous and can brick your system, you'll also need to set your application to elevate with UAC otherwise you'll be met with an Access Denied error. Additionally, the users own environment variables are stored in HKEY_CURRENT_USER\Environment, again be careful as you could potentially brick the users profile and/or applications if you mess around too much.
Source: My own, I've did the bricking in the past in order to find it out myself. RIP to all those Windows installations.
If you are just changing the environment variables for your applications process only (IE. Internet Explorer and other Applications keep the standard ones issued by Windows) then you can simply do the following:
Code: Select all
// Append the applications default folder to the %Path% variable.
Put $Path & ";" & The DefaultFolder Into $Path
BUT!!!
Be warned this area is dangerous and can brick your system, you'll also need to set your application to elevate with UAC otherwise you'll be met with an Access Denied error. Additionally, the users own environment variables are stored in HKEY_CURRENT_USER\Environment, again be careful as you could potentially brick the users profile and/or applications if you mess around too much.
Source: My own, I've did the bricking in the past in order to find it out myself. RIP to all those Windows installations.
Re: Changing Windows Environmental Variables
Thanks for the info. The shell command looks promising, especially since I'm currently using batch files to set the environment variables.
I'll give it a try and see what happens.
I'll give it a try and see what happens.