changing %ProgramFiles%
I wanted to do a test and change the default system c:\Program Files path.
I can see in my registry that it is given the value %ProgramFiles%. I assumed I could initialize the default value by creating a new system environment variable "ProgramFiles" from the control panel, but when I create it with my new value it does not work
I am saying create the environment variable since there is none after Windows install from what I can see in the control panel/System. The thing though, is if I do "set" in the console, I can see the system has another way to initialize it since ProgramFiles has already a value.
How can I change the default c:\Program Files path used by the system ?
Hi,
If you really want to change the location of program files, you can do it by editting the registry. Just run "regedit" and navigate to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" find the ProgramFilesDir key and change the value to the new directory.
cheers,
Paul June A. Domag
Yes, but the value of this key is %ProgramFiles%, so I wanted to change the value of %ProgramFiles% instead. Do you know how to change it ?
I tried to create a new environment variable "ProgramFiles" from Control Panel/System/Advanced but "ProgramFiles" remains unchanged when I restart the console and do "set"
Hi,
The %ProgramFiles% variable is being used by the system to identify on where the Program Files folder is located, thus installing all applications in the folder. So if you want to change its value you must change the "ProgramFilesDir" key in the registry location that I pointed out. The key with the value "%ProgramFiles%" is "ProgramFilesPath". The value of ProgramFilesDir must be the folder location of the designated program files. So you must change this key and not the ProgramFilesPath.
cheers,
Paul June A. Domag
OK, thank you, what you explained works.
A few extra questions:
- I have some hard coded c:\Program Files path in my application (this is really wrong I know !). So I should use ProgramFilesDir instead, right ?
- are there some foreign Windows where the default is not c:\Program Files
- Changing ProgramFilesDir does not modify the value of %ProgramFiles% (the value of ProgramFiles remains the same when I restart the Windows console and do "set"), this value cannot be changed ?
The x64 versions of Windows are affected by this. An application running in Wow64 mode actually has the default of Program Files(x86).
Another time where the hardcoded path doesn't work well is if you have windows installed on another drive, which is possible with dual boot machines.
bob yoplait wrote: |
| OK, thank you, what you explained works. A few extra questions: - I have some hard coded c:\Program Files path in my application (this is really wrong I know !). So I should use ProgramFilesDir instead, right ? - are there some foreign Windows where the default is not c:\Program Files - Changing ProgramFilesDir does not modify the value of %ProgramFiles% (the value of ProgramFiles remains the same when I restart the Windows console and do "set"), this value cannot be changed ? | |
Hi,
I'm not quite sure on why the %ProgramFiles% variable was not changed. Though it should. Once you change the ProgramFilesDir registry entry (and reboot) the %ProgramFiles% variable should also change.
In some localized version of windows, some of it has C:\Programs (C:\Programme) as its programsDir. So I guess you'd better use the ProgramFilesDir.
I'll try and search other methods and inform you if there's something.
cheers,
Paul June A. Domag
I didn't know I had to reboot. If I reboot it works !! Thanks.
Originally, I just restarted the console. It is enough to reinitialize environment variables usually. But %ProgramFiles% is not like the other environment variables it looks like. It seems to be initialized by the system with the value of ProgramFilesDir, and cannot be changed after that.
Since ProgramFilesPath value is %ProgramFiles%, it has the same value also
Creating an environment variable %ProgramFiles% will not modify this behaviour, even after reboot.
How do you call this kind of environment variable owned and intialized by the system that cannot be changed ?