先上一个完整代码
<!-- Name -ASP在线解压,压缩东西 copyright -剧本之家() --> <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <title>接待利用ASP在线解压,压缩东西</title> <body> <TABLE border=0 width=80% align=center cellspacing=1 cellpadding=3> <tr> <th bgcolor="#33CCFF"> </th> </tr> <tr> <td bgcolor="#33CCFF"> <% Server.ScriptTimeout=99999 Dim winrar,cmddir Winrar="C:\Program Files\WinRAR\Winrar.exe" '压缩文件(Winrar)的地点 cmddir="%windir%\system32\cmd.exe" 'cmd.exe(呼吁提示符)的地点 user="csisp" '本措施的用户名 pwd="csisp" '本措施的登岸、压缩、解压缩暗码,请各人务必修改(至少8位以上的组合暗码才够安详!) if request.Form("user")=user and request.Form("pwd")=pwd then response.write "本文件夹路径:"&Server.Mappath(".")&"<br>" from=request.Form("from") where=request.Form("where") if from<>"" and where<>"" then Dim a,b,Shell,Runing,Runcode,Cmd if instr(where,":")=0 then a=Server.mappath(""&where&"") else a=where if instr(from,":")=0 then b=Server.mappath(""&from&"") else b=from 'response.Write b if right(b,1)<>"\" and left(right(b,4),1)<>"." then b=b&".rar" On Error Resume Next Set Shell = Server.CreateObject("WScript.Shell") if request.QueryString("action")=1 then '解压缩 if not ReportFileStatus(b)then Response.Write("没有找到 "&b&"大概不存在!"):Response.End() Runing= cmddir&" /c """&winrar&""" x -ibck -t -y -o+ -p"&pwd&" " '配置运行解压缩的呼吁。 Cmd=Runing&b&" "&a&"\" elseif request.QueryString("action")=0 then '压缩文件 if (not ReportFileStatus(a)) and (not ReportFolderStatus(a)) then Response.Write("没有找到 "&a&"大概不存在!"):Response.End() Cmd= cmddir&" /c del /f /q "&b Runcode = Shell.Run(Cmd,1,True) Runing= cmddir&" /c """&winrar&""" a -ibck -y -ep -o+ -p"&pwd&" " '压缩。 Cmd=Runing&b&" "&a else '删除文件 Cmd= cmddir&" /c del /f /q "&b end if Runcode = Shell.Run(Cmd,1,True) Runing = Shell.Run(cmddir&" /c taskkill /im winrar.exe",1,false) Runing = Shell.Run(cmddir&" /c exit",1,false) Set Shell=nothing ErrInfo %> <%else%> <form method="post" action="?action=1"> --------------------------------------<strong>解压缩文件</strong>--------------------------------------- <br> <br> 请输入rar压缩文件地点: <input value="1.rar" size="50"><br> 解压到:<input value="." size="50"> 文件夹请利用绝对路径且在最后加 "\" <br> <br> <input type="submit" value=" 解 压 "><input type="hidden" value="<%=request.Form("user")%>"> <input type="hidden" value="<%=request.Form("pwd")%>"> </FORM> <form method="post" action="?action=0"> --------------------------------------<strong>压缩文件</strong>---------------------------------------<br> <br> 请在此输入您要压缩文件地点: <input value="./data/dvbbs7#.mdb" size="50"> 您也可以输入文件夹<br> <br> 存放路径及新文件名:<input value="../data/1.rar" size="50"> 自动包围同名文件<br> <br> <input type="submit" value=" 压 缩 "><input type="hidden" value="<%=request.Form("user")%>"> <input type="hidden" value="<%=request.Form("pwd")%>"></FORM> <% ErrInfo end if else login() end if Sub ErrInfo if not isempty(Runcode) and Runcode=0 Then Response.Write("操纵乐成执行,您提交的操纵如下:<br>"& Cmd) elseif not isempty(Runcode) then Response.Write("操纵执行失败!大概您的权限不足可能该措施无法在DOS(呼吁提示符)下运行,您提交的操纵如下:<br>" & Cmd) else end if If Err Then Response.Write "<br>"&err.description err.Clear End If %> <form method="post" action="?action=2"> --------------------------------------<strong>删除文件</strong>---------------------------------------<br> <br> 请输入要删除文件地点:<input size="50" value=<%=from%>> 文件夹请利用绝对路径且在最后加“\” <br> <input type="hidden" value=<%if where<>"" then response.Write where else response.Write "."%>> <br> <input type="submit" value=" 删 除 "> <input type="hidden" value="<%=request.Form("user")%>"> <input type="hidden" value="<%=request.Form("pwd")%>"> </FORM> <br> <% End Sub Function ReportFileStatus(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") ReportFileStatus=false If (fso.FileExists(filespec)) Then ReportFileStatus = true Set fso =nothing End Function Function ReportFolderStatus(fldr) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") ReportFolderStatus=false If (fso.FolderExists(fldr)) Then ReportFolderStatus = true Set fso =nothing End Function Sub login() %> <form method="post" action="?action=2"> <p>--------------------------------------<strong>登岸系统</strong>---------------------------------------<br> <br> 用户名: <input value="csisp"> </p> 密 码: <input type="password"> <br> <br> <input type="submit" value=" 登岸 "> </FORM> <%End sub%> </td> </tr> <tr> <td bgcolor="#FFFFFF"> Copyright ©2008 <a href="https://www.jb51.net">剧本之家</a></td> </tr> </table> </body>