How to find all exe files on client

I’m trying to retrieve all exe files on client.
I tried the following relevance but it returns a few results. It seems the "descendant " inspector works properlly if I specify deeper directory…

example1

names of find files “*.exe” of descendant folders of folder "C:"

exmaple2

pathnames of descendants whose (name of it as lowercase ends with “.exe”) of folders "" of drives whose (type of it=“DRIVE_FIXED”)

Reference:
http://www-01.ibm.com/support/docview.wss?uid=swg21505913

Why does it not retrieve all the files?
Is there any way to find all files on drives? (for example, all files on “C” drive)

Regards,
Eri

Keep in mind that this will likely result in a LARGE list of files.

Don’t try to use Relevance for this. It will take too long and tie the client up needlessly.
A better way to get the paths of all EXE’s (or any other file type) on a system is to use a Task.

The reason is that Relevance has to operate under the constraints of the BES Client. By default it will Work for 10ms then Sleep for 480ms, and repeat. This means that the BES Client spends MOST of the it’s time sleeping rather than gathering the results of the Relevance. And while the client is trying to evaluate the results of your query, it won’t process any other information. Not a good use of the BES Client’s available cycles.

A Task will operate at “normal” CPU speeds just like any other program launched by the Client.

It’s better to use a Task that looks something like this …

// Remove any existing output files
Delete "{pathname of parent folder of client & "\exe-list.txt"}"
Delete __createfile

// Create a batch file to generate the output
create file until ##END##
C:
CD \
DIR /A:H-HS-S /S /B *.exe > "{pathname of parent folder of client & "\exe-list.txt"}"
##END##

move __createfile "GenerateEXEList.bat"
// Execute the script
wait "GenerateEXEList.bat"

You can then retrieve the results from the Task by using the following relevance in an Analysis …

if (exists file "exe-list.txt" of Parent Folder of Client) THEN (Lines of File "exe-list.txt" of Parent Folder of Client) ELSE (Nothing)

When I use tasks like this, I also create a second task that will Delete the exe-list.txt file so that I can clean things up later. I don’t like leaving “extra” files hanging around if I don’t need to.

2 Likes

This is very good advice! One additional element to consider is that rather than loading this information into the BigFix database via a property, depending on the use case/requirements, you may simply be able to upload the resulting exe-list.txt via the Upload Manager ( http://www.ibm.com/support/knowledgecenter/SS63NW_9.2.0/com.ibm.tem.doc_9.2/Platform/Config/c_upload_manager.html ) to the Root Server.

Thanks for your advice. It works in my test environment.

Let me ask you another question.
Is it possible to retrieve exe file name and its version list using task?

example:

(FileName) (Version)
aaa.exe 1.0.0.0
bbb.exe 1.2.000
ccc.exe 5.0

I believe so.

Since it is actually a CMD session gathering the files, it would need to be a two step process.

One to generate the initial file “exe-list.txt” and a second to establish the Version information, assuming it exists. It can all still be in the same Task.

Again, this will likely be fairly “expensive” in terms of client cycles, but not as bad a trying to locate all the EXE’s via Relevance.

The code you would add to the end of the existing Task would be something like …

// Only continue if exe-list.txt exists
continue if {exists file "exe-list.txt" of Parent Folder of Client}

create file until ##END##
{(pathname of it, versions of it) of Files (lines of file "exe-list.txt" of Parent Folder of Client)}
##END##
move __createfile "{pathname of parent folder of client}\exe-versions.txt"
1 Like

Also, in case you hadn’t seen it, this functionality (and more) is included with the BigFix Inventory product:

https://www.hcltechsw.com/products/bigfix/offerings/inventory

Thank you for the reply.
I tried your additional scripts and get the result from “exe-versions.txt” using the sample relevance (I just changed the name of the file)

The property result returned “error” and it contains three dot leader like this:

...
...
...
...

I noticed that the exe-versions.txt contains the file & version list but linefeed or separator do not exist.
How should I deal with this?

Eri

I updated your sample like below.

Action Script:

// Remove any existing output files
Delete "{pathname of parent folder of client & "\exe-list.txt"}"
Delete "{pathname of parent folder of client & "\exe-versions.txt"}"
Delete __createfile

// Create a batch file to generate the output
createfile until ##END##
C:
CD \
DIR /A:H-HS-S /S /B *.exe > "{pathname of parent folder of client & "\exe-list.txt"}"
##END##

move __createfile "GenerateEXEList.bat"
// Execute the script
wait "GenerateEXEList.bat"

// Only continue if exe-list.txt exists
continue if {exists file "exe-list.txt" of Parent Folder of Client}

createfile until ##END##
{("::" & name of it, versions of it) of Files (lines of file "exe-list.txt" of Parent Folder of Client)}
##END##
move __createfile "{pathname of parent folder of client}\exe-versions.txt"

Relevance in Analysis:

if (exists file "exe-versions.txt" of Parent Folder of Client) THEN (substrings separated by "::" of lines of File "exe-versions.txt" of Parent Folder of Client) ELSE ("N/A")

Hi Tim ,

move __createfile “GenerateEXEList.bat” always fails. how can i fix it ?

// Remove any existing output files

Delete "{pathname of parent folder of client & “\exe-list.txt”}"
Delete "{pathname of parent folder of client & “\exe-versions.txt”}"
Delete __createfile

// Create a batch file to generate the output
createfile until ##END##
C:
CD
DIR /A:H-HS-S /S /B *.exe > “{pathname of parent folder of client & “\exe-list.txt”}”
##END##

move __createfile “GenerateEXEList.bat”
// Execute the script
wait “GenerateEXEList.bat”

// Only continue if exe-list.txt exists
continue if {exists file “exe-list.txt” of Parent Folder of Client}

createfile until ##END##
{("::" & name of it, versions of it, size of it, creation time of it, location of it, sha1 of it) of Files (lines of file “exe-list.txt” of Parent Folder of Client)}
##END##
move __createfile "{pathname of parent folder of client}\exe-versions.txt

I’m guessing you’ve run the task on the target at least once already, so the .bat file likely already exists.

You need to add a command to delete the batch file before you rename/move the new one.

Add the following line just before the “Move __createfile …” line.

Delete “GenerateEXEList.bat”

1 Like

Hi yes it is true. i run the task once before “failed move ***”

"Delete “GenerateEXEList.bat” " works great

Thank you.