1

I'm trying to do a simple if like this

if %REGEDIT_HOME%=="" (
    echo.
    echo Forms6i not present
    echo.
) else (
    for /f "skip=1 tokens=3" %a in ('reg query %REGEDIT_HOME% > %LOGDIR%\tmp.txt') do (
        echo. > nul
    ) 
)

The problem is that since the REGEDIT_HOME is in fact null I get an error
) was unexpected at this time.

2 Answers 2

2
if "%REGEDIT_HOME%"=="" (

The match is a literal string - it must be exactly the same on both sides of the == to be true.

or

you could use

if  defined REGEDIT_HOME (

which obviously reverses the logic you've used.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your answer. Both ways are valid to me, but the for loop problem maintains...since the REGEDIT_HOME variable is empty, I get the error: > was unexpected at this time. Z:\CSP\deploys> for /f "skip=1 tokens=3" %a in ('reg query "" > z:\csp\d eploys\logs\0\tmp.txt') do (
escape it with the caret ^
Like this - %REGEDIT_HOME% ^> %LOGDIR%
0

"" is not an empty string. It is two doublequotes.

If the variable is empty, your if is interpreted as:

if =="" (

which gives you the error.

So you will have to check

if "%REGEDIT_HOME%"=="" (...

If the variable is empty, it is interpreted as:

if ""=="" (

1 Comment

Thank you for your answer. I got past the empty variable in the IF, but the for loop problem maintains...since the REGEDIT_HOME variable is empty, I get the error: > was unexpected at this time. Z:\CSP\deploys> for /f "skip=1 tokens=3" %a in ('reg query "" > z:\csp\d eploys\logs\0\tmp.txt') do (

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.