File scan within each user folder?

Comments

4 comments

  • Jason Hanks

    Hi Chris,

    At the current time, wildcards are not allowed to be used in the path of the folders, only in the file names themselves.  In the case of what you're trying to accomplish, you'll have to scan the top level folder of C:\Users.

    0
    Comment actions Permalink
  • Dwreese

    Copy this to a text file and save as .cmd file.

    Lines 2-5 get the C:\User or C:\Documents and Settings depending on OS version.

    Line 7 does the hard work... First, the For statement gets a list of directories in %UDir% which will be a list of user names with paths, then the ForFiles statement searches each of those paths (plus the extra path you want searched) for .txt files (the /M part).  The /C part of ForFiles is the command line you want executed on each file found.  You could copy the files to a UNC path the deploy user has write permission to, or anything else!  The FindStr command just quiets most of the extraneous output generated when directories or files are not found in the process.

    These commands should work on Vista up.  Without the findstr command, it should work on Win2k and up, but you may see more (ignorable) error messages or blank lines.  Hope this has given you a starting point.  Good Luck!

    @Echo Off Set UDir=Unknown If Exist "%SystemDrive%\Users" Set UDir=%SystemDrive%\Users If Exist "%SystemDrive%\Documents and Settings" Set UDir=%SystemDrive%\Documents and Settings If %UDir%=="Unknown" Goto End

    For /d %%d in ("%UDir%\*") Do ForFiles /P "%%d\AppData\Roaming\Microsoft\Signatures" /M *.txt /C "Cmd /C Echo @Path" | FindStr ".txt"

    :End Set UDir=

    0
    Comment actions Permalink
  • Dwreese

    Wow, that copy/paste went strange.

    I am attaching a working cmd script to this reply.

    0
    Comment actions Permalink
  • Chris Davidson

    Jason - I can functionally, but not practically, do what I'm trying to accomplish via C:\Users\ as signatures can be named anything, so (as you alluded to) I would need to pull every single text file in the C:\Users folder and filter out on path in the collections. This is obviously untenable, as the result on a single test machine returned 1800 rows and took ~10 secs to complete.

    Can we consider "a way to scan all the user folders" a feature request? I know it's inbuilt to Windows to use HKU for similar scanning of the registry (and I use it a lot), but it would be fairly handy to have a [Users] base folder for the purposes of file scanning.

     

    Dwreese - I get that info currently with PDQ Deploy and a similar powershell script, but I was hoping on using the dynamic collection aspect of PDQ Inventory. Thanks for the script, though, that should come in handy if I can't send out a PS.

    Thanks,
    -Chris

    0
    Comment actions Permalink

Please sign in to leave a comment.