1

Is it possible to specify which version of a file to call when there are duplicates of it on your PATH variable?

Background

I have both mingw32 and mingw64's bin folders on my path such that

PATH=...;C:\mingw32\bin;C:\mingw64\bin;...

and each folder contains the gcc, g++ etc. executables. is it possible to specify which one should be called, other than to prepend the specific one i want to the start of the path like

PATH=C:\mingw64\bin;%PATH%

for dll's that live in the folder, the 32 or 64bit dll seems to be loaded correctly from windows own methods, but as for other operations im unsure how / (or even) if this is possible.

6
  • 1
    No, it'll always run according to PATH precedence. Why not create separate batch files to call the versions you want?
    – Karan
    Apr 16, 2015 at 1:08
  • thats what i have done when building boost and such. i was more curious if there was a way to just do it so i didn't have to use a batch file for anytime i wanted to call 32/64bit gcc Apr 16, 2015 at 1:18
  • let's suppose there was a way, but it was a command and the command wasn't short, then you'd still probably want a batch file to do it! besides a batch file calling the absolute path, another way would be renaming the exes.. But indeed, I don't think even linux has some special way, and if linux doesn't then cmd wouldn't. Powershell can have many things that linux bash doesn't, but I doubt it has. But let's suppose there was a way, how do you think you'd use it, it'd still require some parameter to state which to use. So even then a batch file would be pretty much just as good.
    – barlop
    Apr 16, 2015 at 1:42
  • There could be a way to do this, but I dunno if it works and if it does only for the case of 32/64bit executables not arbitrary ones. The WindowsOnWindows64 emulation makes it so that e.g. the variable %programfiles% will point to C:\program files for 64bit processes and C:\program files (x86) for 32bit processes. So if you include your files as subfolders of the respective program files and include the path via the default %programfiles%\ variable it might do the right thing because one of the folders will always be non existing. Can't say I'm sure about it though
    – Syberdoor
    Apr 16, 2015 at 6:18
  • Based on which criteria do you want to select the file to run? Who shall do that selection? Apr 16, 2015 at 10:00

0

You must log in to answer this question.

Browse other questions tagged .