rar實現asp的在線壓縮與解壓縮

來源:互聯網
上載者:User
前提:
需要wscript支援
你將cmd.exe和winrar檔案夾中rar.exe都放到同一個檔案夾裡
而且這個檔案夾取名叫"dos",要不然你自己修改代碼檔案也成;
(主要是方便,我自己也很懶的,呵呵)
檔案儲存為同名的檔案哦

自解壓代碼檔案
unrar.asp

<%
dim afterunzip,PEDM,Mlpath,Shell,rarcomm,RetCode,cmd,comm,fso 

unfilepath=Request.ServerVariables("PATH_INFO")
<|>response.write Mlpath
<|>response.end

<|>存放RAR.EXE和CMD.EXE的路徑 
Mlpath=Replace(Server.mappath(unfilepath),"unrar.asp","")

<|>解壓檔案後所放的路徑
afterunzip=Server.mappath("dos")&"\" 
<|>afterunzip=Mlpath

<|>要解壓的RAR檔案
PEDM=Server.mappath("aaa.rar")

Set Shell = Server.CreateObject("WScript.Shell") 
<|>x從檔案檔案中全路徑釋放檔案
<|>t壓縮後測試檔案
<|>o不覆蓋已經存在的檔案
<|>p設定口令
rarcomm= Mlpath&"cmd.exe /c "&Mlpath&"rar.exe x -t -o+ -p- " 
cmd=rarcomm&PEDM&" "&afterunzip
RetCode = Shell.Run(cmd,1, True) 
%>

<|><|><|><|><|><|><|><|><|><|><|><|>壓縮檔代碼
rar.asp

<%
dim ylj,ywj,Mlpath,Shell,rarcomm,RetCode,cmd,comm,fso 

unfilepath=Request.ServerVariables("PATH_INFO")
<|>response.write Mlpath
<|>response.end

<|>存放RAR.EXE和CMD.EXE的路徑 
Mlpath=Replace(Server.mappath(unfilepath),"rar.asp","")

<|>壓縮檔後所放的路徑
afterzip=Server.mappath("dos")&"\" 
<|>ylj=Mlpath

<|>要壓縮的RAR檔案
needzip=Server.mappath("aaaw.rar")

Set Shell = Server.CreateObject("WScript.Shell") 
<|>x從檔案檔案中全路徑釋放檔案
<|>t壓縮後測試檔案
<|>o不覆蓋已經存在的檔案
<|>p設定口令
rarcomm= Mlpath&"cmd.exe /c "&Mlpath&"rar.exe a -o+ " 
cmd=rarcomm&needzip&" "&afterzip
<|>Response.write cmd
<|>Response.end
RetCode = Shell.Run(cmd,1, True) 
%>

要改成winzip的自己改吧,提供命令列參考:

WinRAR<命令>-<開關><壓縮包><檔案...><解壓縮路徑> 

壓縮與解壓縮操作舉例 

下面我們通過例子,對比一下Winzip和Winrar的基本壓縮與解壓縮操作命令。假設壓縮包檔案名稱為test.zip和test.rar。 

任務描述
Winzip     Winrar

壓縮目錄test及其子目錄的檔案內容
Wzzip test.zip test –r -P
WINRAR A test.rar test –r

刪除壓縮包中的*.txt檔案
Wzzip test.zip *.txt -d
WinRAR d test.rar *.txt

重新整理壓縮包中的檔案,即添加已經存在於壓縮包中但更新的檔案
Wzzip test.zip test –f
Winrar f test.rar test

更新壓縮包中的檔案,即添加已經存在於壓縮包中但更新的檔案以及新檔案
Wzzip test.zip test –u
Winrar u test.rar test

移動檔案到壓縮包,即添加檔案到壓縮包後再刪除被壓縮的檔案
Wzzip test.zip –r –P –m
Winrar m test.rar test –r

添加全部 *.exe 檔案到壓縮檔,但排除有 a或b 開頭名稱的檔案
Wzzip test *.exe -xf*.* -xb*.*
WinRAR a test *.exe -xf*.* -xb*.*

加密碼進行壓縮
Wzzip test.zip test –s123。注意密碼是大小寫敏感的。在圖形介面下開啟帶密碼的壓縮檔,會看到+號標記(附圖1)。
WINRAR A test.rar test –p123 –r。注意密碼是大小寫敏感的。在圖形介面下開啟帶密碼的壓縮檔,會看到*號標記(附圖2)。

按名字排序、以簡要方式列表顯示壓縮包檔案
Wzzip test.zip -vbn
Rar l test.rar

鎖定壓縮包,即防止未來對壓縮包的任何修改
無對應命令
Winrar k test.rar

建立360kb大小的分卷壓縮包
無對應命令
Winrar a –v360 test

     
帶子目錄資訊解壓縮檔案
Wzunzip test -d
Winrar x test -r

不帶子目錄資訊解壓縮檔案
Wzunzip test
Winrar e test

解壓縮檔案到指定目錄,如果目錄不存在,自動建立
Wzunzip test newfolder\
Winrar x test newfolder\

解壓縮檔案並確認覆蓋檔案
Wzunzip test -y
Winrar x test –y

解壓縮特定檔案
Wzunzip test *.txt
Winrar x test *.txt

解壓縮現有檔案的更新檔案
Wzunzip test –f 
Winrar x test –f

解壓縮現有檔案的更新檔案及新檔案
Wzunzip test -n
Winrar x test -u

批量解壓縮檔案
Wzunzip *.zip
WinRAR e *.rar

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.