how to change chocolatey default location from program data to program files

1.3k Views Asked by At

Is it possible to change chocolatey default location to c:/program files so that all the applications goes into program files instead of program data.

1

There are 1 best solutions below

2
On

This is kind of unnecessary as most packages which run EXE or MSI based installers will usually install to the default path for that program, and Chocolatey generates shims on the PATH for the packages which don't reference a proper installer.

That said, you can install Chocolatey to a different location by setting ChocolateyInstall environment variable to the directory you want before running the install.ps1 script (note this environment variable should be persisted at the System level).


You can also move the install location to a new place, just make certain to update the same environment variable with the new path. Again, this will only change Chocolatey's internal working path and any packages which rely on MSI or EXE installers will usually install to their default location under Program Files and Program Files (x86).

Once you update $env:ChocolateyInstall, you will also need to update your System PATH variable to add the new value of $env:ChocolateyInstall\bin to it as the PATH will still reference the old location. This is important because some packages will have Shim Executables generated and placed in the bin folder.


For packages which install programs that don't have EXE or MSI based installers, Chocolatey generates Shim Executables which point at any executables extracted to $env:ChocolateyInstall\lib\package-id\tools. These shims are placed in $env:ChocolateyInstall\bin which is on the PATH if you have Chocolatey installed.

To run these, the shims should have the same filename as the executable they ultimately run. So you would just need to invoke the program by name as you would with any other CLI utility available on the PATH. One issue to watch out for is with shims whose associated executable would normally accept piped data; the shims will not pass the piped data through to the calling executable.

In this case you would have to use the actual executable for piping data, which is once again going to be available somewhere under $env:ChocolateyInstall\lib\package-id\tools.