Articles

using wild card in env variable

June 3, 2011 at 06:28:59
Specs: Windows 7

I have some env variables like

ANSYS009_DIR

ANSYS110_DIR

ANSYS120_DIR

As you can see the difference is the number among them. I want to write a batch file and first check if one of these variables exits. I know that this code will do that for one variable

IF "%ANSYS110_DIR%" == "" GOTO NOPATH
:YESPATH
@ECHO The PATH environment variable was detected.
GOTO END
:NOPATH
@ECHO The PATH environment variable was NOT detected.
GOTO END
:END

However I want to know how can I use wild char?? For example %ANSYS*_DIR% doesn't work.

please share any suggestion on that


See More: using wild card in env variable

Report •


#1
June 3, 2011 at 09:59:53

I think the problem is that the variable is defined exactly. I dont think that there is an option to wildcard a variable, becuase of this. the %ANSYS*_DIR% counts as a variable, and as you havent defined it, it wont work. you might be able to pipe the "path command into a text file and look through that?

mike


Report •

#2
June 3, 2011 at 10:02:28

i ment set sorry

mike


Report •

#3
June 4, 2011 at 00:55:58

ok for few variables it is possible to do a brute force check. I was seeking a general solution for that.

Report •

Related Solutions


Ask Question