asp结合RAR.exe实现压缩全站asp

/ / 2025-02-23   阅读:2557
asp结合RAR.exe实现压缩全站...
<%@ Language=VBScript %>
<%
' 设置RAR.exe的路径
Dim rarPath
rarPath = Server.MapPath("inc/RAR.exe")

' 设置要压缩的文件夹路径
Dim sourceFolder
sourceFolder = Server.MapPath("/")

' 设置压缩文件的保存路径和文件名
Dim targetArchive
targetArchive = Server.MapPath("/123.rar")

' 构建RAR命令
Dim rarCommand
rarCommand = """" & rarPath & """" & " a -r " & """" & targetArchive & """" & " " & """" & sourceFolder & """"

' 创建WshShell对象来执行命令
Dim shell
Set shell = CreateObject("WScript.Shell")

' 执行RAR命令
On Error Resume Next
Dim result
result = shell.Run(rarCommand, 0, true)
On Error GoTo 0

' 检查命令执行结果
If result = 0 Then
    Response.Write "文件夹压缩成功!"
Else
    Response.Write "文件夹压缩失败!"
End If

' 释放对象
Set shell = Nothing
%>


我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈