开发者

Programming in a batch script

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:\che开发者_C百科ckhere\
ELSE
wmic=c:\checkthisone\
CONTINUE


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%


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜