winrar|壓縮|winrar|壓縮
伺服器用WScript.Shell組件調用winrar中的rar.exe,在代碼的同目錄要上傳cmd.exe和rar.exe
用法:rar.asp?path=要壓縮的檔案夾&rarname=壓縮後的檔案名稱&includefolder=包括子檔案夾就不會空
<%
'用法http://xx/rar.asp?path=要壓縮的檔案夾&rarname=壓縮後的檔案名稱&includefolder=包插子檔案夾就不會空,
on error resume next
AppPath=server.mappath(".")&"\" '存放RAR.EXE和CMD.EXE的路徑
zipfolder=server.mappath(request("path"))&"\" '要壓縮的檔案或檔案夾
rarfile = request("rarname")
thispath = server.mappath(".")&"\"
if zipfolder<>"" and rarfile<>"" then
Set Shell = Server.CreateObject("WScript.Shell")
if err.number<>0 then
response.write "伺服器不支援"
response.end
end if
if request("includefolder")<>"" then
cmd= thispath&"cmd.exe /c "&thispath&"rar.exe a -ep1 -r -t -o+ "&thispath&rarfile&" "& zipfolder &""
else
cmd= thispath&"cmd.exe /c "&thispath&"rar.exe a -ep1 -t -o+ "&thispath&rarfile&" "& zipfolder &""
end if
'response.write cmd
RetCode = Shell.Run(cmd,1, True)
response.write "<a href='"&rarfile&"'>"&rarfile&"</a>"
if err.number<>0 then
response.write "<a href='"&rarfile&"'>"&rarfile&"</a>"
else
response.write err.description
end if
else
response.write "沒有參數"
end if
%>