Hi,

Our antivirus is not perfect and I am trying to create a script that would detect executables files in the following folders:

C:\Documents and Settings\All Users

C:\Documents and Settings\%user%

I have managed to detect a specific file in a specific folder, but I can't figure out to make a search on *.exe files

Thanks in advance for your help

3 Comments   [ + ] Show Comments

Comments

  • this maybe?

    @ECHO OFF

    :: [- look & delete in specified folders -]

    Pushd "%userprofile%\"
    for %%f in (*.exe) do del %%f /f

    Exit /B
  • Don't run that script if you want to KEEP the exe files - I read it as the OP wants to DETECT, not delete the .exe files.
  • sorry, my bad! Use this powershell script I wrote:

    For Win7:

    Get-ChildItem -filter "*.exe" -Recurse c:\Users\* | Out-File -FilePath c:\list.txt

    For XP:

    Get-ChildItem -filter "*.exe" -Recurse c:\Documents and Settings\* | Out-File -FilePath c:\list.txt
Please log in to comment

Community Chosen Answer

1

you can use wmic calls to search this out

wmic process where "name like '%.exe'" get name   will return all running exe's

WMIC.exe PROCESS where (executablepath like "%%AppDat%%") get executablepath will show all running exe's in a user appdata structure

also see for vb script to search for exe

http://www.pctools.com/forum/archive/index.php/t-19886.html

Answered 09/26/2013 by: SMal.tmcc
Red Belt

Please log in to comment

Answers

0

Apologies for posting so far after the fact, getting caught up on some threads. 

May not be what you are looking for exactly, but I did something similar recently where I was trying to find *.wav files on systems.  As you'd imagine, I also wanted to exclude certain directories because this is a common file type, much like .exe files.  After a decent amount of research, I found robocopy to be my best solution.

On Windows 7 x64 systems, I'd run this script:

IF NOT EXIST \\%SERVER%\Inventory\WAV_FILES\%computername% MD \\%SERVER%\Inventory\WAV_FILES\%computername%
Robocopy.exe C:\ %TEMP% *.wav /S /XD Windows "Program Files" "Program Files (x86)" /XJ /L /NC /NDL /NP /NJH /NJS >\\%SERVER%\Inventory\WAV_FILES\%computername%\%computername%_wav.txt

The above script will verify a folder exists on a defined path, create if not - perform a search for all *.wav files, using the /XD to exclude certain paths.  Results will be written to a text file in the referenced location.  Modify accordingly for x86 or Windows XP.

HTH

Answered 10/15/2013 by: drose23
Second Degree Blue Belt

Please log in to comment
Answer this question or Comment on this question for clarity