@echo off
set "rar=C:\Program Files\7-Zip\7z.exe"
for /r %%i in (*.rar *.zip) do "%rar%" x -ad -y %%i %%~dpi
pause
设置环境变量
@echo off
rem 设置 7z.exe 的路径
set 7z_path=C:\Program Files\7-Zip\7z.exe
rem 检查 7z.exe 是否存在
if not exist "%7z_path%" (
echo 7z.exe not found at %7z_path%
exit /b 1
)
rem 添加 7z.exe 到 PATH 环境变量
setx PATH "%PATH%;%7z_path%"
rem 设置 7z.exe 为默认的解压程序
assoc .zip=7zFile
ftype 7zFile="%7z_path%" x %%1
echo 7z.exe is set as the default extractor for zip files