0

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
3
  • 1
    Can you tell us under which circumstances wmic resides not in its default location and/or its path is not present in the PATH environment variable? Commented Jun 24, 2010 at 15:06
  • I've tried: SET PATH=%PATH%;C:\WINDOWS\SYSTEM32\WBEM\ SET PATH=%PATH% Which both failed. WMIC is installed in sys*32\wbem operable program or batch file. getting patch information 'C:\WINDOWS\SYSTEM32\WBEM\' is not recognized as an internal or external command Commented Jun 24, 2010 at 15:29
  • By default wmic is in the PATH. It's also considered a good idea to leave the system PATH as it is (there are exceptions but most of he time they don't apply). Commented Jun 24, 2010 at 18:28

2 Answers 2

1

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%
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

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.