标题: 请大家帮我看看下面的多重解压批处理参数是否正确
[打印本页]
作者: xiaoyunwang
时间: 2008-10-11 13:57
标题: 请大家帮我看看下面的多重解压批处理参数是否正确
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 文件[.扩展名] [-x]>>%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 ]
作者: xiaoyunwang
时间: 2008-10-11 14:01
附一个摘录的英文帮助信息,如有用过这些压缩软件的朋友,帮我一下
Microsoft (R) Cabinet Extraction Tool - Version (16) 1.00.603.0 (08/14/97)
Copyright (c) Microsoft Corp 1994-1997. All rights reserved.
EXTRACT [/Y] [/A] [/D | /E] [/L dir] cabinet [filename ...]
EXTRACT [/Y] source [newname]
EXTRACT [/Y] /C source destination
cabinet - Cabinet file (contains two or more files).
filename - Name of the file to extract from the cabinet.
Wild cards and multiple filenames (separated by
blanks) may be used.
source - Compressed file (a cabinet with only one file).
newname - New filename to give the extracted file.
If not supplied, the original name is used.
/A Process ALL cabinets. Follows cabinet chain
starting in first cabinet mentioned.
/C Copy source file to destination (to copy from DMF disks).
/D Display cabinet directory (use with filename to avoid extract).
/E Extract (use instead of *.* to extract all files).
/L dir Location to place extracted files (default is current directory).
/Y Do not prompt before overwriting an existing file.
PKUNZIP (R) FAST! Extract Utility Version 2.50 03-01-1999
Copr. 1989-1999 PKWARE Inc. All Rights Reserved. Shareware Version
PKUNZIP Reg. U.S. Pat. and Tm. Off.
Usage: PKUNZIP [options] zipfile [@list] [files...]
-c[m] extract files to Console [with More]
-d restore/create Directory structure stored in .ZIP file
-e[c|d|e|n|p|r|s] Extract files. Sort by [CRC | Date | Extension | Name
| Percentage | Reverse | Size]
-f Freshen files in destination directory
-j|J<a,h,r,s> mask|don't mask <Hidden/System/Readonly> files (def.=jahrs)
-n extract only Newer files
-o Overwrite previously existing files
-p[a/b][c][#] extract to Printer [Asc mode,Bin mode,Com port] [port #]
-q Enable ANSI comments
-s[pwd] Decrypt with password [If no pwd is given, prompt for pwd]
-t Test .ZIP file integrity
-v
[r][m][t] View .ZIP [Brief][Reverse][More][Technical] sort by [CRC|
[c,d,e,n,o,p,s] Date|Extension|Name|natural Order(default)|Percentage|Size]
-x<filespec> eXclude file(s) from extraction
-$ Restore volume label on destination drive
-@listfile Generate list file
Press 2 for advanced/trouble shooting options.
Press any other key to quit help.
If you use PKUNZIP on a regular basis you are strongly encouraged to register
it. With a full registration you will receive a comprehensive printed manual,
the latest version of PKZIP, PKUNZIP & PKSFX software, and discounts on
future upgrades of PKZIP for DOS and other platforms. See the documentation
for ordering and commercial & distribution licensing information.
PKWARE, Inc. Internet: www.pkware.com Phone: 414-354-8699
9025 N. Deerwood Drive Sales: sales@pkware.com Fax: 414-354-8559
Brown Deer, WI 53223 Tech supp.: support@pkware.com BBS: 414-354-8670
Usage: UHARC command [-switches..] archive[.uha] [files..@listfile..!exclude..]
---< Commands >----------------------------------------------------------------
a create archive and Add files e Extract files to current directory
m create archive and Move files x eXtract files with full pathname
l List files in archive t Test files in archive
---< Switches >----------------------------------------------------------------
d<0..2> Set display mode (0 = quiet, 1 = default, 2 = verbose)
m<0..3,x,z> Set cmp.mode (0 = STORE, 1..3 = ALZ:fast..best, x = PPM, z = LZP)
md<n> Set dictionary size in KByte (must be power of 2 : 1 .. 32768)
mm[-,+] Disable/enable built-in multimedia detection/compression
o[-,+,p] Overwrite existing files (- = never, + = always, p = prompt)
p<-,r,f,e> Store (- = no, r = relative, f = full, e = excluded) pathnames
ph[-,+] Archive header encryption | ac[-,+] Clear file archive attr
pw[passwd] Set password | ae<attr> Set attr exclusion mask
r[-,+] Recurse subdirectories | b<n> Set max filebuffer size
t<dir> Set extract target dir | bpb[-,+] bpb instead of % ratio
vm[-,+] Set virtual memory usage | ed[-,+] Store empty directories
y[-,+] Assume yes on all queries | lg<file> Log output to <file>
-------------------------------------------------------------------------------
UNARJ (Demo version) 2.65 Copyright (c) 1991-2002 ARJ Software, Inc.
Can't open /?.ARJ
UNDISK Version 1.6 Pro, expand all floppy disk image files tools
Copyright 1993.7,1995.2 (c)HomeSoft, written by Zhi-Hong Feng
Registered to [PD User] Compile Date:1996-11-15
[Usage] UNDISK Filename [target dir] [/OPTION | -OPTION]
Thanks: Jun Lei, written DUP pack-image file expand code
Hong Sun, Wan-jiang Wang, Guo-xiang qian, Wei Ye, Xin-yu Li,
Meng-lei Zhang test working
/?,/H Help!
/C Use chinese message
/E Use english message
/Fn expand image use format N
/G Ignore error
/I DIR IMAGE
/Lnnnn expand image use head size nnnn
/M expand file to mutli-directory
/N Only expand new files
/O overwrite previously existing files
/P Pause when expand a image
/V set target diskette volume
IMAGE Format code(more message see UNDISK.DOC):
1 DUP 3.0 8 DEC DISKIMAG
2 DISKDUPE 9 DISK CLONER
3 HD-COPY 1.7x 10 Sab Diskette
4 QCOPY Pro 11 DEC DUPDISK
5 COPYQM 12 PCSS COPYEZ
6 HD-COPY 1.7? 13 SWDI 3.3
7 Disk Image
Thank you use my UNDISK, if you have trouble, please call to me:
BP: 010-62568800 call 80486 Email:bjbroad@netchina.co.cn
My Name is: Zhi-Hong Feng
If you used CCDOS, UNDISK will print Chinese char and more message.
UNRAR 3.30 freeware Copyright (c) 1993-2004 Eugene Roshal
Usage: unrar <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract\>
<Commands>
e Extract files to current directory
l[t,b] List archive [technical, bare]
p Print file to stdout
t Test archive files
v[t,b] Verbosely list archive [technical,bare]
x Extract files with full path
<Switches>
- Stop switches scanning
ad Append archive name to destination path
ap<path> Set path inside archive
av- Disable authenticity verification check
c- Disable comments show
cfg- Disable read configuration
cl Convert names to lower case
cu Convert names to upper case
dh Open shared files
ep Exclude paths from names
f Freshen files
idp Disable percentage display
ierr Send all messages to stderr
inul Disable all messages
kb Keep broken extracted files
o+ Overwrite existing files
o- Do not overwrite existing files
p[password] Set password
p- Do not query password
r Recurse subdirectories
ri<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms
ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format
tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format
tn<time> Process files newer than <time>
to<time> Process files older than <time>
ts<m,c,a>[N] Save or restore file time (modification, creation, access)
u Update files
v List all volumes
ver[n] File version control
vp Pause before each volume
x<file> Exclude specified file
x@ Read file names to exclude from stdin
x@<list> Exclude files in specified list file
y Assume Yes on all queries