How to check location of 32bit Program Files folder in windows .bat script
batch-file, file, location, windows
Solution
You could just check for its existence & store the path;
@echo off & setLocal enabledelayedexpansion
if exist "C:\Program Files\app1.exe" (
set PPATH="C:\Program Files\"
) else (
set PPATH="C:\Program Files(x86)\"
)
start "" %PPATH%app1.exe
start "" %PPATH%app2.exe
start "" %PPATH%app3.exe
Problem
I want to write .bat script which works under all flavours of Windows, no matter if 32 or 64 bit. In this script I want to run some file.exe. That file is located in C:\Program Files\ under 32-bit systems or C:\Program FIles (x86)\ under x64 systems. I can write: "%ProgramFiles(x86)%\file.exe" under 64bit systems or "%ProgramFiles%\file.exe" under 32bit systems but I want to make the script universal. Is there any way of determining that path universally?