Kaseya Community

Agent Procedure to check if file exists and then report back via email of the location on each computer

This question is not answered

Hello,

My client is trying to remove a particular file that has many version to it so we are also trying to use a wildcard. FileName_*.*

Does anyone know of a script that will scan all drives and report back if the file is found. I have tried the TestFile, but it appears it needs the full path to work.

Thanks,

Brendan

All Replies
  • If the file is not stored in a known path then it will be very complicated to script, could it be that there might be a registry key or an ini file one each computer that specifies the path?

    If not the only way would be to use a more advanced scripting language like Vbscript or Powershell that will allow you to search for these files and remove them and then use Kaseya agent procedures to execute the scripts.

  • Whats the file name ?

    Does it have a .exe extesnion ?

  • We haver a procedure that searches for PST files and outputs to a text file on the machine, Which could easily be edited to email or alert you.

    executeShellCommand (Dir /b /s /d C:\* C:\%username_%computer%_PST_Files.txt)

  • execute shell command

    for /f %D in ('wmic volume get name') do @dir %D /b /s /a 2>nul | findstr /i "PARTIAL_FILE_NAME" >> c:\found_files.txt

    test file

    c:\found_files.txt

    if file contains

    :\

    send mail (under the if)

    ###########################

    The above is a rough explanation of what you can do with the kaseya procedure editor

    note that PARTIAL_FILE_NAME should not include the asterisks, so in your example above you used FileName_*.* but in this example you would just use FileName_

  • If you want to go down that route why not specify the file in the DIR command saves a bit of time/resources eg:

    for /f %D in ('wmic volume get name') do @dir %DFileName_*.* /b /s /a 2>nul