Command Line Bar Variable Comparison

I am trying to compare my computer name with some given string. From reading on google, namely http://commandwindows.com/batchfiles-branching.htm , I tried to execute the following and many variations 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% it seems to always take a "still taken" branch.

Any help regarding why the ( EXIT ) case fails / what syntax error I am making will be appreciated.

+6
source share
1 answer

Try the following:

 if "%ComputerName%"=="A513242" (exit) else (echo "else taken") 
+12
source

Source: https://habr.com/ru/post/917990/


All Articles