Getting the correct “Program Files” directory in 32 vs 64 bit from a .cmd file

We have several deployment scripts that have to run on both 32-bit and 64-bit environments. Until now, we just modified the script with a “replace all’ command for the 64-bit, which had to use “C:Program Files (x86)” instead of the traditional “C:Program Files” directory. This was my first attempt: set BTDFProgFiles="%programfiles(x86)%" if %BTDFProgFiles%=="" set BTDFProgFiles="%programfiles%" […]