/build/static/layout/Breadcrumb_cap_w.png

Trying to find a file on local C: Drives

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:

FileExists(c:\users\%USERPROFILE%\AppData\Roaming\Microsoft\Credentials\7EF1626F3BE739BD33A9CB19BBADBE61)
FileExists(c:\users\%username%\AppData\Roaming\Microsoft\Credentials\7EF1626F3BE739BD33A9CB19BBADBE61)

Having no luck.  I have a PC that I know it exists on and the username is mjohnson, so if I do
FileExists(c:\users\mjohnson\AppData\Roaming\Microsoft\Credentials\7EF1626F3BE739BD33A9CB19BBADBE61)
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

Answers (7)

Posted by: SMal.tmcc 8 years ago
Red Belt
3
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
lwPqWE.jpeg

4ONzZ1.jpeg

Comments:
  • Works, AWESOME, Thank you! - fcorker 8 years ago
  • 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? - fcorker 8 years ago
  • Actually, even the PC that has the file returned "File Not Found" :( - fcorker 8 years ago
    • 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 - SMal.tmcc 8 years ago
      • Trying now, thanks! - fcorker 8 years ago
      • Ran inventory on a machine I know has it, no dice. is the /S to search subdirectories? - fcorker 8 years ago
      • yes - SMal.tmcc 8 years ago
      • Still said File Not Found... - fcorker 8 years ago
      • let me name a file to that exact name and test, give me a few minutes. - SMal.tmcc 8 years ago
Posted by: SMal.tmcc 8 years ago
Red Belt
2

ok used this line

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

l1qc2J.jpeg


here are the results

d5IFRs.jpeg


Comments:
  • Sorry, I had left work yesterday...let me try this, thanks! - fcorker 8 years ago
    • ITNinja's are in all time zones, you never know where the person you are helping is. - SMal.tmcc 8 years ago
  • 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? - fcorker 8 years ago
    • I even tried it with a non-hidden file in a different directory, same result - fcorker 8 years ago
    • could be. on the machine it is on right click and check it's properties. we can get around that if it is so. - SMal.tmcc 8 years ago
      • 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. - fcorker 8 years ago
      • print screen - paste into paint and crop for better detail - SMal.tmcc 8 years ago
      • 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 - SMal.tmcc 8 years ago
      • 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) - SMal.tmcc 8 years ago
      • you can email direct if easier, smal.tmcc@gmail.com - SMal.tmcc 8 years ago
      • 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! - fcorker 8 years ago
      • 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! - fcorker 8 years ago
      • Any suggestions on a fairly easy report I could set up to run daily and look for positive results? - fcorker 8 years ago
      • 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. - SMal.tmcc 8 years ago
      • 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 - SMal.tmcc 8 years ago
      • 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! - fcorker 8 years ago
Posted by: SMal.tmcc 8 years ago
Red Belt
1
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
Posted by: fcorker 8 years ago
Senior Yellow Belt
1
The report runs, waiting on the scheduled to run in about 10 minutes...thank you very much, this was a HUGE help!
Posted by: rileyz 8 years ago
Red Belt
0
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.
Posted by: fcorker 8 years ago
Senior Yellow Belt
0
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.


Posted by: SMal.tmcc 8 years ago
Red Belt
0
the report






 
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