Unzip a password protected file in vbsript

孤者浪人 提交于 2021-01-20 13:38:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!