Create a custom inventory rule for a folder inside a users folder

Looking to create a custom inventory rule for .squirrel sql under users account to see which PCs have squirrel installed. I am unable to create a CIR for location at which SQuirrel is installed because they may not be in the same location or name but the .squirrel sql folder is consistent.

DirectoryExists(C:\users\%username%\squirrel sql)

Any help/tips would be great!

0 Comments   [ + ] Show comments

Answers (2)

Posted by: Nico_K 1 year ago
Red Belt

this will not work since the agent runs as SYSTEM and therefore it will not show anything you need.

YOu need to create a batch or powershell script and put it in a readable folder.
Then you can run it via a custom inventory rule.
If the script runs long, you should run it regulary via Scripting and put the results into this folder and read the results with the CIR.

Posted by: JordanNolan 1 year ago
9th Degree Black Belt

As Nico_K mentioned, the Kace agent does run as the system account, however I do find that the search for User registry settings does search the current logged on user profile.  For example we know the system account does not map drives, but the RegistryValueReturn() function returns values from HKCU for the currently logged in user for me.  If squirrel sql adds user registry keys you can retrieve those.  This example returns a user's mapped P: Drive for me

RegistryValueReturn(HKCU\Network\p, RemotePath, TEXT)

If it does not, you can probably use the ShellCommandTextReturn(command) to search if the folder exists and return a Yes or No value.  You can use the query session command and parse it to find the currenly logged in user, then search if a folder exists under that user profile.

query session returns:

Session NameUsernameIDStateType

Here is an example of checking if the Desktop folder is present for the currently active user logged in:

for /f "tokens=1-4" %a in ('query session') do @if "%a"==">console" IF EXIST %SYSTEMDRIVE%\Users\%b\Documents (Echo YES) else (Echo No)

So I believe you would be looking for something like:

ShellCommandTextReturn(cmd /c for /f "tokens=1-4" %a in ('query session') do @if "%a"==">console" IF EXIST %SYSTEMDRIVE%\Users\%b\squirrel (Echo YES) else (Echo No))

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