设为首页 加入收藏

TOP

调用winrar压缩文件夹
2011-05-31 17:59:21 来源: 作者: 【 】 浏览:637次 评论:0
服务器用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
%>
您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇ASP做的剪包锤游戏 下一篇限制某段IP地址

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位