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

Cancel

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.

• Hi dugullett!
This looks like the exact thing I need. Thanks so much for taking the time to reply!
• 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
• 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!
• 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)

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

-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