How can I search for a missing PATH entry using a custom inventory rule?


I'm new to the forum, so please let me know if I miss any pertinent information.

My goal is to create an inventory of systems missing the %systemroot%\system32; entry in the default Windows %PATH% environment variable. 
I've isolated the registry key: HKLM\System\CurrentControlSet\Control\Session Manager\Environment

I'm unsure what logic I can use within the k1000 custom inventory rule prompt to find these systems. If there is another post dedicated to custom inventory rules please let me know and I will post there instead (I didn't see one when I searched).

0 Comments   [ + ] Show comments

Answers (3)

Posted by: SMal.tmcc 5 years ago
Red Belt
The easiest was you can do this is
ShellCommandTextReturn(set path)

Then create a report that has a filter using your cir contains ;%systemroot%\system32;

Also when I checked my machine my path is ;c:\windows\system32; not %systemroot%

If you want it to show just that entry to be the only path portion in the cir you would need to pipe this command into a for do loop to filter for that.

  • The shell command I have used to check for C:\windows system32 is [code] echo.%path% | findstr /i /c:"c:\windows\system32;" [/code] and outputs a 0 on find or a 1 on fail. Will the cir understand the 0/1? - Proto84 5 years ago
    • thanks, my bad got mixed up in my head, pipe to a findstr not a for do loop since they are only looking for a single return - SMal.tmcc 5 years ago
      • My question now is will this inventory rule only give me computers that give a return 0? - Proto84 5 years ago
      • On a machine you have run this on, does the CIR show under the machines details "custom inventory fields"? it should be a 1 or 0 in that detail. - SMal.tmcc 5 years ago
Posted by: SMal.tmcc 5 years ago
Red Belt
I tried your findstr and it returned a lot of stuff, I have some time to test now will post back a working one shortly

your findstr CIR

Posted by: SMal.tmcc 5 years ago
Red Belt
I think it is best just to do what I originally said and ShellCommandTextReturn(set path) and create a report with a filter that CIR is not null and CIR does not contain ;c:\windows\system32;

I came up with this and as a batch file it runs great, only returns the error level of 0 or 1

echo off & echo %path% | find /i "c:\windows\system32;" & cls & echo %ERRORLEVEL%
you could create a batch file attach it to the cir and then use a MI to install the batch to your machines and then call the batch file with a ShellCommandTextReturn CIR and it will give you just the 0 or 1 state.  I do something like that to get a clean list of admins on my systems.

Anyway here is the cir you have in mind but since ShellCommandTextReturn records all steps of the process you are still stuck with the %path% in the cir.

shellcommandtextreturn(cmd /q /c echo %path% | find /i "c:\windows\system32;" & cls & echo %ERRORLEVEL%)
and you get this


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