【问题标题】:Zipping a folder using 7-Zip from an asp page使用 7-Zip 从 asp 页面压缩文件夹
【发布时间】:2013-08-20 15:39:53
【问题描述】:

我正在尝试从 asp 页面压缩文件夹。这是我的代码:

zipFolderName=folderName &"Zipped.zip"
command="cd C:\Program Files\7-Zip & "
command = command & "7z a -tzip " & zipFolderName & " """ & folderName & """"
Response.Write command

set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing

Response.Write中写的命令是

cd C:\Program Files\7-Zip & 7z a -tzip D:/saveAll/DocumentsZipped.zip "D:/saveAll/Documents" 

当我在 cmd 窗口中运行此命令时,它工作得很好。但是我的asp页面显示错误:

WshShell.Exec error '80070002' 

系统找不到指定的文件。

错误出现在 objShell.exe 命令行上。

我做错了什么?请帮忙!

【问题讨论】:

    标签: asp-classic vbscript cmd 7zip


    【解决方案1】:

    您需要将C:\Program Files\7-Zip 放在双引号之间,因为路径包含一个空格。另外,cd& 是 CMD 内置的,所以你需要在 CMD 中运行命令行。

    改变这个:

    command="cd C:\Program Files\7-Zip & "
    

    进入这个:

    command = "%COMSPEC% /c cd ""C:\Program Files\7-Zip"" & "
    

    【讨论】:

    • 谢谢!现在完美运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    相关资源
    最近更新 更多