views:

50

answers:

2

Hey all I have a simple problem I was hoping someone can give me assistance with. I'm trying to get WMIC to return output however on different machines, the executable is in different directories. Is there a method to check all directories I list to get it to run, e.g.:

IF EXIST
wmic=c:\checkhere\
ELSE
wmic=c:\checkthisone\
CONTINUE
A: 

As an option You could add all of them to the PATH variable and simply run wmic.

Sergius
+1  A: 

The following is a simple way of setting an environment variable to some path that has a file you are looking for. A rather brain dead way but easy to understand/change:

if exist c:\path1\some.exe set asdf=c:\path1\
if exist c:\path2\some.exe set asdf=c:\path2\
if exist c:\path3\some.exe set asdf=c:\path3\
if %asdf%x=x goto couldnotfindit
set path=%path%;%asdf%
Mark Wilkins