Installation file analysis tool (batch processing bat) FOR WIN7



Disclaimer: I am limited, I welcome criticism and corrections, illegal use is prohibited, please keep the code pure and complete

Tool description: The tool analyzes which files are installed according to the file adding time. There may be false negatives and false positives, which can be corrected by viewing the log file and file list file

Update: Test environment win7, modified a time judgment bug


@echo off
setlocal enabledelayedexpansion
echo 安装文件分析工具
echo.
echo make by humors221
echo.
set /p input=请输入安装包完整路径(带后缀):
echo.
set /p where=请输入待分析路径(驱动或目录):
echo.
echo 开始记录!
echo.
set tmpstart=%time:~0,5%
set startTime=%date:~0,10% !tmpstart: =0!
echo 开始时间:!startTime!
set startTime=!startTime:/=!
set startTime=!startTime: =!
set startTime=!startTime::=!
echo.
start /wait %input%
set tmpend=%time:~0,5%
set endTime=%date:~0,10% !tmpend: =0!
echo.
echo 结束时间:!endTime!
echo.
echo 结束记录!
set endTime=!endTime:/=!
set endTime=!endTime: =!
set endTime=!endTime::=!
echo.
echo 开始分析%where%目录
echo.
set dire=
set file=
set total=0
set isOk=0
set fullPath=
set idx=1
echo.>日志.txt
echo.>文件列表.txt
for /f "tokens=*" %%d in ('dir /AD /S /B "%where%"') do (
echo.
echo 分析%%d目录...
echo 分析%%d目录...>>日志.txt
set dire=%%d
call :fil
)
echo 共!total!个文件>>文件列表.txt
echo 分析完毕!请查看日志“日志“文件或”文件列表“文件
pause
exit

:fil
for /f "tokens=*" %%f in ('dir /A-D /B /O-D /TA "!dire!"') do (
echo.
echo 分析%%f文件...
echo 分析%%f文件...>>日志.txt 
set file=%%f
set idx=1
set fullPath=!dire!\!file!
call :info
if !isOk! EQU -1 (
exit /b
)
)

:info
for /f "tokens=1,2,* delims= " %%a in ('dir /O-D /TA "!fullPath!"') do (
if !idx! EQU 4 (
set dt=%%a %%b
set cmpdt=%%a %%b
set cmpdt=!cmpdt:/=!
set cmpdt=!cmpdt: =!
set cmpdt=!cmpdt::=!
if "!cmpdt!" GEQ "!startTime!" (
if "!cmpdt!" LEQ "!endTime!" (
echo 添加了!fullPath!文件,时间!dt!...>>文件列表.txt
set isOk=0
set /a total+=1
exit /b
) else (
echo !fullPath!不是添加的文件,时间!dt!...>>日志.txt
set isOk=0
exit /b
)
) else (
echo !fullPath!不是添加的文件,时间!dt!...>>日志.txt
set isOk=-1
exit /b
)
)
set /a idx+=1
)



Guess you like

Origin blog.csdn.net/humors221/article/details/61615469