问题
i am facing a trouble here,Could you please tell me how to unzip a password protected field in vbscript? I have a code which runs perfectly,but it asking password each time when it runs
pathToZipFile="C:\folder.zip"
extractTo="C:\"
set sa = CreateObject("Shell.Application")
set filesInzip=sa.NameSpace(pathToZipFile).items
sa.NameSpace(extractTo).CopyHere(filesInzip)
I need a code which will not ask password in run,Please help,Thank you!!
回答1:
AFAIK the Shell.Application
object doesn't support providing a password. Try 7-zip instead:
pass = "..."
zipfile = "your.zip"
CreateObject("WScript.Shell").Run "7za.exe x -p" & pass & " " & zipfile, 0, True
If necessary add the path to 7za.exe
and/or file.zip
. If the path contains spaces, you'll also need to put double quotes around it, e.g. like this:
Function qq(str) : qq = Chr(34) & str & Chr(34) : End Function
zipfile = qq("C:\path\with spaces\to\your.zip")
来源:https://stackoverflow.com/questions/18327217/unzip-a-password-protected-file-in-vbsript