unpack.bat 在 A: 中,希望批处理判断压缩包类型,并解压到内存盘 %ramdrive% 中,保留压缩包中的路径结构,不使用确认提示,直接替换已经存在的同名文件,标签 :_noexec1 处使用的参数是否正确啊?万分感谢!
@echo off
rem 这个软件用来解压多种压缩包到内存盘中
rem 如果解压失败则赋值 unpackerr=1
rem 如果带 -x 参数则运行解压后的 autorun.bat 批处理
if "%1"=="/?" goto _help
if "%1"=="" goto _help
set unpack_f=
:_cab
echo %1|find /i ".cab">NUL
if errorlevel 1 goto _rar
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.cab fpath %1.cab|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.cab set unpack_f=%%a%1.cab
for %%a in (%path%) do if exist %%a\%1.cab set unpack_f=%%a\%1.cab
if "%unpack_f%"=="" goto _nofile
set flag_f=cab
goto _unpack
:_rar
echo %1|find /i ".rar">NUL
if errorlevel 1 goto _zip
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.rar fpath %1.rar|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.rar set unpack_f=%%a%1.rar
for %%a in (%path%) do if exist %%a\%1.rar set unpack_f=%%a\%1.rar
if "%unpack_f%"=="" goto _nofile
set flag_f=rar
goto _unpack
:_zip
echo %1|find /i ".zip">NUL
if errorlevel 1 goto _arj
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.zip fpath %1.zip|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.zip set unpack_f=%%a%1.zip
for %%a in (%path%) do if exist %%a\%1.zip set unpack_f=%%a\%1.zip
if "%unpack_f%"=="" goto _nofile
set flag_f=zip
goto _unpack
:_arj
echo %1|find /i ".arj">NUL
if errorlevel 1 goto _uha
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.arj fpath %1.arj|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.arj set unpack_f=%%a%1.arj
for %%a in (%path%) do if exist %%a\%1.arj set unpack_f=%%a\%1.arj
if "%unpack_f%"=="" goto _nofile
set flag_f=arj
goto _unpack
:_uha
echo %1|find /i ".uha">NUL
if errorlevel 1 goto _img
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.uha fpath %1.uha|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.uha set unpack_f=%%a%1.uha
for %%a in (%path%) do if exist %%a\%1.uha set unpack_f=%%a\%1.uha
if "%unpack_f%"=="" goto _nofile
set flag_f=uha
goto _unpack
:_img
echo %1|find /i ".img">NUL
if errorlevel 1 goto _ima
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.img fpath %1.img|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.img set unpack_f=%%a%1.img
for %%a in (%path%) do if exist %%a\%1.img set unpack_f=%%a\%1.img
if "%unpack_f%"=="" goto _nofile
set flag_f=img
goto _unpack
:_ima
echo %1|find /i ".ima">NUL
if errorlevel 1 goto _iso
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.ima fpath %1.ima|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.ima set unpack_f=%%a%1.ima
for %%a in (%path%) do if exist %%a\%1.ima set unpack_f=%%a\%1.ima
if "%unpack_f%"=="" goto _nofile
set flag_f=ima
goto _unpack
:_iso
echo %1|find /i ".iso">NUL
if errorlevel 1 goto _err
call vtm /p 要提取 .ISO 镜像请运行 Vcdrom 虚拟光驱
goto _end
:_err
call vtm /p 不支持的文件格式,无法解压 %1
goto _end
:_unpack
if exist %ramdrive%\autorun.bat del %ramdrive%\autorun.bat
for %%a in (cab rar zip arj uha img ima) do if "%flag_f%"=="%%a" goto _noexec1
call vtm /p 不支持的文件格式,无法解压 %unpack_f%
goto _end
:_noexec1
call vtm /p UNPACK: 正在解压 "%unpack_f%"
if "%flag_f%"=="cab" extract.exe /y /l %ramdrive%\ /e %unpack_f% > %tmp%\extract.out
if "%flag_f%"=="rar" UNRAR.exe x -y %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="zip" PKUNZIP.exe -d -o %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="arj" UNARJ.exe x %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="uha" UHARC.exe x -y+ -t%ramdrive%\ %unpack_f% > %tmp%\extract.out
if "%flag_f%"=="img" UNDISK.exe %unpack_f% %ramdrive%\ /M /O > %tmp%\extract.out
if "%flag_f%"=="ima" UNDISK.exe %unpack_f% %ramdrive%\ /M /O > %tmp%\extract.out
if errorlevel 1 goto _unpackerr
set unpackerr=
if not exist %ramdrive%\autorun.bat goto _end
if not "%2" == "-x" goto _noexec
shift
for %%i in (9 8 7 6 5 4 3 2 1 0) do if not exist %ramdrive%\_autoru%%i.bat set unpack_a=_autoru%%i.bat
ren %ramdrive%\autorun.bat %unpack_a%
call %ramdrive%\%unpack_a% %2 %3 %4 %5 %6 %7 %8 %9
if not "%unpackerr%" == "" goto _end
for %%i in (0 1 2 3 4 5 6 7 8 9) do if exist %ramdrive%\_autoru%%i.bat set unpack_a=_autoru%%i.bat
del %ramdrive%\%unpack_a%
set unpack_a=
:_noexec
if exist %ramdrive%\autorun.bat del %ramdrive%\autorun.bat
goto _end
:_nofile
echo.
call vtm /p UNPACK: 未找到压缩文件 "%1".
goto _end
:_unpackerr
if exist %tmp%\extract.out type %tmp%\extract.out
echo.
call vtm /p UNPACK: 解压文件 "%1" 时出错.
set unpackerr=1
goto _end
:_help
echo 解压 cab/rar/zip/arj/uha/img/ima 到内存盘和虚拟ISO镜像.>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 用法: unpack 文件 >>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 参数 -x 表示解压"文件"到内存盘后并运行其中的 autorun.bat>>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 注意: 当解压失败时赋值环境变量 unpackerr=1 判断。>>%tmp%\_tmp.txt
call vtm /t %tmp%\_tmp.txt
del %tmp%\_tmp.txt>NUL
:_end
if exist %tmp%\extract.out del %tmp%\extract.out
set unpack_f=
set flag_f=
[ Last edited by xiaoyunwang on 2008-10-11 at 14:05 ]
@echo off
rem 这个软件用来解压多种压缩包到内存盘中
rem 如果解压失败则赋值 unpackerr=1
rem 如果带 -x 参数则运行解压后的 autorun.bat 批处理
if "%1"=="/?" goto _help
if "%1"=="" goto _help
set unpack_f=
:_cab
echo %1|find /i ".cab">NUL
if errorlevel 1 goto _rar
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.cab fpath %1.cab|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.cab set unpack_f=%%a%1.cab
for %%a in (%path%) do if exist %%a\%1.cab set unpack_f=%%a\%1.cab
if "%unpack_f%"=="" goto _nofile
set flag_f=cab
goto _unpack
:_rar
echo %1|find /i ".rar">NUL
if errorlevel 1 goto _zip
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.rar fpath %1.rar|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.rar set unpack_f=%%a%1.rar
for %%a in (%path%) do if exist %%a\%1.rar set unpack_f=%%a\%1.rar
if "%unpack_f%"=="" goto _nofile
set flag_f=rar
goto _unpack
:_zip
echo %1|find /i ".zip">NUL
if errorlevel 1 goto _arj
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.zip fpath %1.zip|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.zip set unpack_f=%%a%1.zip
for %%a in (%path%) do if exist %%a\%1.zip set unpack_f=%%a\%1.zip
if "%unpack_f%"=="" goto _nofile
set flag_f=zip
goto _unpack
:_arj
echo %1|find /i ".arj">NUL
if errorlevel 1 goto _uha
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.arj fpath %1.arj|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.arj set unpack_f=%%a%1.arj
for %%a in (%path%) do if exist %%a\%1.arj set unpack_f=%%a\%1.arj
if "%unpack_f%"=="" goto _nofile
set flag_f=arj
goto _unpack
:_uha
echo %1|find /i ".uha">NUL
if errorlevel 1 goto _img
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.uha fpath %1.uha|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.uha set unpack_f=%%a%1.uha
for %%a in (%path%) do if exist %%a\%1.uha set unpack_f=%%a\%1.uha
if "%unpack_f%"=="" goto _nofile
set flag_f=uha
goto _unpack
:_img
echo %1|find /i ".img">NUL
if errorlevel 1 goto _ima
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.img fpath %1.img|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.img set unpack_f=%%a%1.img
for %%a in (%path%) do if exist %%a\%1.img set unpack_f=%%a\%1.img
if "%unpack_f%"=="" goto _nofile
set flag_f=img
goto _unpack
:_ima
echo %1|find /i ".ima">NUL
if errorlevel 1 goto _iso
if exist %1 fpath %1|nset unpack_f=$1
if exist %1.ima fpath %1.ima|nset unpack_f=$1
for %%a in (%path%) do if exist %%a%1 set unpack_f=%%a%1
for %%a in (%path%) do if exist %%a\%1 set unpack_f=%%a\%1
for %%a in (%path%) do if exist %%a%1.ima set unpack_f=%%a%1.ima
for %%a in (%path%) do if exist %%a\%1.ima set unpack_f=%%a\%1.ima
if "%unpack_f%"=="" goto _nofile
set flag_f=ima
goto _unpack
:_iso
echo %1|find /i ".iso">NUL
if errorlevel 1 goto _err
call vtm /p 要提取 .ISO 镜像请运行 Vcdrom 虚拟光驱
goto _end
:_err
call vtm /p 不支持的文件格式,无法解压 %1
goto _end
:_unpack
if exist %ramdrive%\autorun.bat del %ramdrive%\autorun.bat
for %%a in (cab rar zip arj uha img ima) do if "%flag_f%"=="%%a" goto _noexec1
call vtm /p 不支持的文件格式,无法解压 %unpack_f%
goto _end
:_noexec1
call vtm /p UNPACK: 正在解压 "%unpack_f%"
if "%flag_f%"=="cab" extract.exe /y /l %ramdrive%\ /e %unpack_f% > %tmp%\extract.out
if "%flag_f%"=="rar" UNRAR.exe x -y %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="zip" PKUNZIP.exe -d -o %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="arj" UNARJ.exe x %unpack_f% %ramdrive%\ > %tmp%\extract.out
if "%flag_f%"=="uha" UHARC.exe x -y+ -t%ramdrive%\ %unpack_f% > %tmp%\extract.out
if "%flag_f%"=="img" UNDISK.exe %unpack_f% %ramdrive%\ /M /O > %tmp%\extract.out
if "%flag_f%"=="ima" UNDISK.exe %unpack_f% %ramdrive%\ /M /O > %tmp%\extract.out
if errorlevel 1 goto _unpackerr
set unpackerr=
if not exist %ramdrive%\autorun.bat goto _end
if not "%2" == "-x" goto _noexec
shift
for %%i in (9 8 7 6 5 4 3 2 1 0) do if not exist %ramdrive%\_autoru%%i.bat set unpack_a=_autoru%%i.bat
ren %ramdrive%\autorun.bat %unpack_a%
call %ramdrive%\%unpack_a% %2 %3 %4 %5 %6 %7 %8 %9
if not "%unpackerr%" == "" goto _end
for %%i in (0 1 2 3 4 5 6 7 8 9) do if exist %ramdrive%\_autoru%%i.bat set unpack_a=_autoru%%i.bat
del %ramdrive%\%unpack_a%
set unpack_a=
:_noexec
if exist %ramdrive%\autorun.bat del %ramdrive%\autorun.bat
goto _end
:_nofile
echo.
call vtm /p UNPACK: 未找到压缩文件 "%1".
goto _end
:_unpackerr
if exist %tmp%\extract.out type %tmp%\extract.out
echo.
call vtm /p UNPACK: 解压文件 "%1" 时出错.
set unpackerr=1
goto _end
:_help
echo 解压 cab/rar/zip/arj/uha/img/ima 到内存盘和虚拟ISO镜像.>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 用法: unpack 文件 >>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 参数 -x 表示解压"文件"到内存盘后并运行其中的 autorun.bat>>%tmp%\_tmp.txt
echo.>>%tmp%\_tmp.txt
echo 注意: 当解压失败时赋值环境变量 unpackerr=1 判断。>>%tmp%\_tmp.txt
call vtm /t %tmp%\_tmp.txt
del %tmp%\_tmp.txt>NUL
:_end
if exist %tmp%\extract.out del %tmp%\extract.out
set unpack_f=
set flag_f=
[ Last edited by xiaoyunwang on 2008-10-11 at 14:05 ]
