I have a batch script, I think my issue has to do with parentheses but I'm not sure how to work around it
This is it
REM Detect if the OS is x86 or x64
IF DEFINED PROGRAMFILES(x86) (
REM x64
SET "_PROGRAMFILES=%PROGRAMFILES(x86)%"
GOTO MAIN_PROGRAM
) ELSE (
REM x86
SET "_PROGRAMFILES=%PROGRAMFILES%"
GOTO MAIN_PROGRAM
)
:MAIN_PROGRAM
SET "MY_EXE=%_PROGRAMFILES%\MYFOLDER\MYEXE.exe"
IF EXIST "%MY_EXE%" (
ECHO YES
) ELSE (
ECHO NO
)
Run this on x86 and its ok as the path to check is C:\Program Files\MYFOLDER\MYEXE.exe
Run this on x64 and it bombs out "not expected at this time"
I'm pretty sure its got to do with the Path C:\Program Files (x86)\
How can I work around the (x86) is thats the issue
NEW
REM Is the OS x86
IF "%PROCESSOR_ARCHITECTURE%" == "x86" (
SET "_PROGRAMFILES=%PROGRAMFILES%"
SET "_ARCH=x86"
ECHO CPU Architecture is: "%_ARCH%"
ECHO Program Files Directory is: "%_PROGRAMFILES%"
GOTO MAIN_PROGRAM
)
REM Is the OS AMD64
IF "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
SET "_PROGRAMFILES=%PROGRAMFILES(x86)%"
SET "_ARCH=x86"
ECHO CPU Architecture is: "%_ARCH%"
ECHO Program Files Directory is: "%_PROGRAMFILES%"
GOTO MAIN_PROGRAM
)
GOTO ERROR_OS_ARCH
:ERROR_OS_ARCH
CLS
cWnd.exe /SHOW @
ECHO.
ECHO Error 100: Operating System Architecture not Supported. Contact your IT Department
ECHO.
EXIT /B