Compression:
<%
Dim quota Dir, rarnamedir, rarsource
Export dir = server. mappath ("dos") & "/" '// The storage path of pai.exeand rar.exe
Rarnamedir = server. mappath ("data") & "/mmgg" '// compress to "mmgg.rar"
Rarsourcedir = server. mappath ("data") & "'// compress the entire" AA "folder
Call RAR (includir, rarnamedir, rarsourcedir)
Sub RAR (byval includir, byval rarnamedir, rarsourcedir)
Dim cmd, Shell
Cmd = cmddir & "cmd.exe/C" & cmddir & "rar.exe A-EP1-O +" '//-EP1-O + each has two switch commands. For details, refer to WinRAR help.
Cmd = cmd & rarnamedir & "& rarsourcedir
On Error resume next
Set shell = server. Createobject ("wscript. Shell ")
If err or isobject (Shell) = false then
If err then err. Clear
Response. Write "no shell operation permission ..."
Response. End
End if
On Error resume next
Shell. Run cmd, 1, true
If err then
Err. Clear
Response. Write "An error occurred while compressing the file. You may not have operation permissions"
Response. End
End if
End sub
%>
Decompress:
<%
Dim ylj, ywj, mlpath, Shell, rarcomm, retcode, CMD, comm, FSO
Mlpath = server. mappath ("dos") & "/" 'stores RAR. EXE and cmd. EXE paths
Ylj = server. mappath ("data") & "/" 'path after extracting the file
Ywj = server. mappath ("data") & "/mmgg.rar" 'The rarfile to be decompressed
Set shell = server. Createobject ("wscript. Shell ")
Rarcomm = mlpath & "cmd.exe/C" & mlpath & "rar.exe X-T-O +-p -"
Cmd = rarcomm & ywj & "& ylj
Retcode = shell. Run (CMD, 1, false)
%>