Re: Any way to escape parenthesis characters in a batch file?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Big Al" <BigAl@xxxxxxxxxxx> wrote in message
news:JLWGj.9189$Oj5.1280@xxxxxxxxxxx
WB wrote:
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
set PROGNAME=Program Files
) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set PROGNAME=Program Files (x86)
)

This fails because of the parenthesis in (x86). I have a workaround
already, but I'd prefer using the method above for readability. Any way
to escape the parenthesis characters so this will work?

I didn't think .bat files would accept if/else commands.
I know 'if exists ... goto' works. I use it to skip to another line in a
batch file, and thus the next line is the else.
But not much else you can do.

They actually do. Try this for fun:

@echo off
if %UserName%==Al (echo Hello Al) else (echo Goodby %Username%)


.



Relevant Pages