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.
Please log in to answer
Posted by: chucksteel 4 years ago
Posted by: flip1001 4 years ago
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"))