9

I've been trying to compare my computername to some pre-set string. From reading around on google, namely http://commandwindows.com/batchfiles-branching.htm, I've attempted the following and many variants of the same line with /I, "%ComputerName", A513242 etc

IF (%ComputerName% == "A513242") (
  EXIT) ELSE (
    ECHO "else taken")

where "A513242" is the result of calling ECHO %ComputerName% this seems to always take the "else taken" branch.

Any help as to why the (EXIT) case is not being taken/ what syntactical mistake I am making would be appreciated.

1 Answer 1

15

Try this:

if "%ComputerName%"=="A513242" (exit) else (echo "else taken")
Sign up to request clarification or add additional context in comments.

2 Comments

Any explanation as to why OP's variant doesn't work?
@klaus triendl - Refer to the accepted answer here: stackoverflow.com/questions/47035821/…

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.