/build/static/layout/Breadcrumb_cap_w.png

Customer Inventory Rule - FileExists

Morning, I have two files under the user profile which I need to add to a custom rule. I have set up two different types of rules and non are working. Any advice?

ShellCommandTextReturn(cmd.exe /c type %userprofile%\appdata\standard.txt)    No results found after inventory



FileExists(%userprofile%\appdata\standard.txt)        No results found

I have followed the KACE help information but I am not getting results, I have add the file to my PC and I am manually checking in.





1 Comment   [ + ] Show comment
  • Just realised KACE runs as system so these variables won't work. - djordan 7 years ago

Answers (2)

Posted by: chucksteel 7 years ago
Red Belt
0
As you found, this won't be possible with a custom inventory rule. You can use a script configured to run as the current user that would report back information, or place results in a file that a custom inventory rule can retrieve. 
Posted by: flip1001 7 years ago
Black Belt
0
I found this code in an older post a couple of years ago, which I modified based on your question.

The rule will search for the file of logged in users. You can try putting both files into separate ShellCommandTextReturn statements with the AND keyword in between.

If you don't want the logged in users, but instead all profiles then I might be able to modify the rule, but I don't have a Windows system available right now.

ShellCommandTextReturn(cmd /q /c for /f "tokens=2 delims=\" %a in ('wmic computersystem get username') do for %A in (%a) do if exist "C:\Users\%A\AppData\standard.txt" (type "C:\Users\%A\AppData\standard.txt"))
 
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