Search for EXE files in a specific folder
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
Answers (2)
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
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
@ECHO OFF
:: [- look & delete in specified folders -]
Pushd "%userprofile%\"
for %%f in (*.exe) do del %%f /f
Exit /B - mattski 11 years ago
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 - mattski 11 years ago