Software Question

Trying to find a file on local C: Drives

06/06/2016 1720 views
I'm trying to find a way during inventory to see if a particular file exists on local C: drive on my computers.  The file is 7EF1626F3BE739BD33A9CB19BBADBE61 which is located under c:\Users\(username)\AppData\Roaming\Microsoft\Credentials.  I need it to look in all of the various user folders that may be present on the C drive.

Following another post in here, it was suggested to create a Custom Inventory item, and under the Custom Inventory Rule, use the FileExists.  I have tried:


Having no luck.  I have a PC that I know it exists on and the username is mjohnson, so if I do
it returns the result properly.

Is there a variable I can use where the username goes so it will search all names under the users folder?
0 Comments   [ + ] Show comments


Community Chosen Answer

CIR's run as system so the user variables are useless to try to use, they will point to the systems profile (who is the user running the command)

create a cir that does this:

ShellCommandTextReturn(dir c:\7EF1626F3BE739BD33A9CB19BBADBE61 /s > %1 & type %1)

here I use a file I know I had to show example

Answered 06/06/2016 by: SMal.tmcc
Red Belt

  • Works, AWESOME, Thank you!
  • Spoke too soon..it's running, however, every PC is getting a result, either the file is there or it is not found, is there a way to limit the response ONLY if the file is found?
  • Actually, even the PC that has the file returned "File Not Found" :(
    • put a dot on the end of the file name, I bet dir is seeing that line as dir vs file. I had an extension on my test
      • Trying now, thanks!
      • Ran inventory on a machine I know has it, no dice. is the /S to search subdirectories?
      • yes
      • Still said File Not Found...
      • let me name a file to that exact name and test, give me a few minutes.

All Answers


ok used this line

ShellCommandTextReturn(dir c:\7EF1626F3BE739BD33A9CB19BBADBE61. /s > %1 & type %1)


here are the results


Answered 06/06/2016 by: SMal.tmcc
Red Belt

  • Sorry, I had left work yesterday...let me try this, thanks!
    • ITNinja's are in all time zones, you never know where the person you are helping is.
  • Well, this looks like exactly what I have in mine, the only difference being that you are Windows 10, I'm on Windows 7 Professional SP1, ad I still get file not found. The CIR is running, I now have 233 devices reporting, but I believe they are all "File Not Found", though I'm trying to confirm on a particular machine that I know has the file. I even just ran this with the full path to the file, and forced inventory, same result. Could it be that it is a Hidden File?
    • I even tried it with a non-hidden file in a different directory, same result
    • could be. on the machine it is on right click and check it's properties. we can get around that if it is so.
      • It is a hidden file, I checked, but I just tried with a non-hidden file, still did not work. How are you inserting your examples above? I can find a way to send you screenshots.
      • print screen - paste into paint and crop for better detail
      • on that machine if you open a command window and run dir c:\7EF1626F3BE739BD33A9CB19BBADBE61. /s /a:h does it return the file?
        I added the /a:h for hidden
      • let try is this way then (add the command interpreter to call dir)
        ShellCommandTextReturn(cmd /c dir c:\7EF1626F3BE739BD33A9CB19BBADBE61. /s /a:h > %1 & type %1)
      • you can email direct if easier, smal.tmcc@gmail.com
      • Running your first suggestion at the command prompt show searching each directory and showing the file in the correct directory. Trying your second suggestion in the CIR returned the proper result, hallaluyah!
      • Running your first suggestion at the command prompt show searching each directory and showing the file in the correct directory. Trying your second suggestion in the CIR returned the proper result, hallaluyah!
      • Any suggestions on a fairly easy report I could set up to run daily and look for positive results?
      • cool, like I tell our techs. Computers are not black and white, they are a lot of grey! I have worked on computers since 1979 so I know a lot of tricks and variations of commands.
      • you can do one with the wizard and then schedule to deliver via email when you want. let me send some screens after lunch (In Reno NV) PST
      • Thank you. Take your time, I'm leaving for the in 10 minutes, I get off at 2:30 EST daily. I REALLY APPRECIATE your assistance! You've been super!
This content is currently hidden from public view.
Reason: Removed by member request For more information, visit our FAQ's.
Answer about eliminating the file not founds.

After you get the cir to work this way,

You can create a findstr command to check the file, that is very complicated.  I can do that if it is absolutely needed. Will need a some time to create, real busy here this time of year.

You do know the cir has run on that machine at least. (file not found)

The easiest thing to do is create a report with a filter that the cir is not null and does not contain "file not found"

You can check the report or schedule it to email you at set intervals
Answered 06/06/2016 by: SMal.tmcc
Red Belt

The report runs, waiting on the scheduled to run in about 10 minutes...thank you very much, this was a HUGE help!
Answered 06/08/2016 by: fcorker
Senior Yellow Belt

The short answer is "no".

But what you can do is list out the "C:\Users" folder names into an array, then use your script to cycle through the usernames/foldernames in the array. You need some script foo to this of course.

What script language are you using?

Keep in mind I dont know anything about KACE, but I can offer scripting advice.
Answered 06/06/2016 by: rileyz
Red Belt

I'm not proficient at scripting unfortunately.  Also, I have approx 250 computers, and users that roam, so each PC has an ever changing list of "users" under there.

Answered 06/06/2016 by: fcorker
Senior Yellow Belt

the report

Answered 06/07/2016 by: SMal.tmcc
Red Belt

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