ASP calls WinRAR compressed folder

Source: Internet
Author: User
Tags empty rar
winrar| compressed server uses Wscript.Shell component to invoke Rar.exe in WinRAR, upload cmd.exe and rar.exe in the same directory as code

Usage: rar.asp?path= The folder you want to compress &rarname= the compressed file name &includefolder= including subfolders will not be empty

<%
' Usage http://xx/rar.asp?path= the folder to be compressed &rarname= the compressed file name &includefolder= The packet-insert subfolder will not be empty,
On Error Resume Next
Apppath=server.mappath (".") & "\" to store RAR.EXE and CMD.EXE paths
Zipfolder=server.mappath (Request ("path")) & "\" files or folders to compress
Rarfile = Request ("Rarname")
Thispath = Server.MapPath (".") & "\"
If zipfolder<> "" and rarfile<> "" Then
Set Shell = Server.CreateObject ("Wscript.Shell")
If Err.number<>0 Then
Response.Write "Server not supported"
Response.End
End If
If Request ("Includefolder") <> "then
cmd= thispath& "cmd.exe/c" &thispath& "Rar.exe a-ep1-r-t-o+" &thispath&rarfile& "" & Zipfol Der & ""
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 "No Parameters"
End If
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.