/build/static/layout/Breadcrumb_cap_w.png

Custom Inventory Rule -- Find files

I want a custom inventory rule that will look for several files that may have different paths.  Is there a way to do a wildcard for the path?  My first guess was FileExists(*winword.exe) but with some research it looks like I need to use REGEX.  I'm just not sure how to execute that.  Thanks,

awingren


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: dugullett 11 years ago
Red Belt
3

I've had to do something similiar and return multiple paths for exe's. I used recursive lookup in a bat file. 

PUSHD "%programfiles%\"

FOR /f "tokens=1-8 delims=\" %%a IN ('DIR /b /s "FIRST.EXE"') DO ECHO %%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h

POPD

 

PUSHD "%programfiles%\"

FOR /f "tokens=1-8 delims=\" %%a IN ('DIR /b /s "SECOND.EXE"') DO ECHO %%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h

POPD

 

PUSHD "%programfiles%\"

FOR /f "tokens=1-8 delims=\" %%a IN ('DIR /b /s "THIRD.EXE"') DO ECHO %%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h

POPD

 

PUSHD "%programfiles%\"

FOR /f "tokens=1-8 delims=\" %%a IN ('DIR /b /s "FOURTH.exe"') DO ECHO %%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h

POPD

 

PUSHD "%programfiles%\"

FOR /f "tokens=1-8 delims=\" %%a IN ('DIR /b /s "FIFTH.exe"') DO ECHO %%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h

POPD

In my case I just looked in Program Files, but you can change to what you need. Just run this and export the contents to a txt file. Then inventory that txt file.


Comments:
  • Hi dugullett!
    This looks like the exact thing I need. Thanks so much for taking the time to reply! - awingren 11 years ago
    • No problem. Keep in mind that if you are going to keep it in %programfiles% that x64 is %programfiles(x86)%. You can create something like

      if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto x64 - dugullett 11 years ago
  • Awesome. Thanks again for your help, dugullett! How do I inventory my output text file? My custom inventory rule is:

    ShellCommandTextReturn(type c:\rf_prt_list.txt)

    It seems like that should do it, but it doesn't work... =/

    Thanks a ton! - awingren 11 years ago
    • Sorry about the late reply. I was going through some old links and saw this. I guess I stopped following it. You need something like this.

      ShellCommandTextReturn(cmd.exe /c type C:\rf_prt_list.txt) - dugullett 11 years ago
Posted by: jknox 11 years ago
Red Belt
2

I haven't tried regex for this, it's an interesting idea.

Given your example, it looks like you are trying to inventory 32 and 64 bit Microsoft Word.  You could just use an OR in the rule:

c:\program files\microsoft office\office14\winword.exe OR c:\program files (x86)\microsoft office\office14\winword.exe

Note: both arguments and the OR need to be on the same line.

You could probably also use a registry entry instead and it might remove the need for a path.  There's a key called bitness that will ID whether Office is 32 or 64 bit.

  • Registry path: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Outlook
  • Registry key: Bitness
  • Value: either x86 or x64

Source: http://technet.microsoft.com/en-us/library/ee681792.aspx

Posted by: AbhayR 11 years ago
Red Belt
-2

You can try with Custom Inventory rule 

FilenamesMatchingRegexReturn(fullpath,regex,type)

Ex: FilenamesMatchingRegexReturn(c:\path\to\folder,bat$,TEXT)

Above CI rule will return all files ending with bat extension.

 

-Abhay

 

 

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ