iT邦幫忙

0

[解決] ASP利用7Z解壓縮檔案問題

各位好

ASP利用7Z解壓縮檔案

  1. 執行無發生錯誤,但ZIP檔案沒有被解壓縮
Response.Write "<BR><BR>解壓縮 : /a004 解壓到 /tempfiles **************************** <BR>"
'來源 zipFolderNamed 
'目的 unzip2folderName
unzip2folderName = Server.mappath("../tempfiles/")
command = "%COMSPEC% /c cd ""C:\Program Files (x86)\7-Zip"" & "
command = command & "7z x " & zipFolderNamed & " -o" & unzip2folderName 
Response.Write command
set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing

202-5-19 問題解決

command = "%COMSPEC% /c cd ""C:\Program Files (x86)\7-Zip"" & "
command = command & "7z x " & zipFolderNamed & "  -o" & unzip2folderName &"\" 

在 unzip2folderName 後面加一 \

  1. 若在"命令提示字元" 是成功的
cmd: cd C:\Program Files (x86)\7-Zip
cmd: 7z x E:\wwwroot\_mytest\a004\20200518154618.zip -oE:\wwwroot\_mytest\tempfiles
  1. 壓縮部分是成功的
'來源
zipFolderNames = Server.mappath("../a003/")

'目的
folderName=Server.mappath("../a004/")
filename = year(date()) & right( "0"& month(date()) ,2)  & right( "0"& day(date()) ,2)  & right( "0"& hour(now()) ,2)  & right( "0"& Minute(now()) ,2) & right( "0"& second(now()) ,2) & right(SMT_pic,4)
zipFolderNamed= folderName &"\"& filename &".zip" 

'目的zipFolderNamed 放前 
command = "%COMSPEC% /c cd ""C:\Program Files (x86)\7-Zip"" & "
command = command & "7z a -tzip " & zipFolderNamed  & " """ & zipFolderNames & """" 
Response.Write command
set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing

請問我的ASP寫法哪裡出問題? 請各位幫忙!

先謝謝各位幫忙!

https://www.ijshgoan.com.tw/tw/drain-soft.html

player iT邦大師 1 級 ‧ 2020-05-18 20:48:29 檢舉
set objshell = Server.CreateObject("WScript.shell")
之後請檢查 objshell 是否為null
因為安全性因素,"WScript.shell"記得很早就被封了
如果你是ASP.NET平台,改用7z.net取代吧
webtest iT邦新手 5 級 ‧ 2020-05-19 08:46:58 檢舉
謝謝2位
問題解決 : 在最後面加 \

command = "%COMSPEC% /c cd ""C:\Program Files (x86)\7-Zip"" & "
command = command & "7z x " & zipFolderNamed & " -o" & unzip2folderName &"\"

尚未有邦友回答

立即登入回答