在 vbsript 中解压缩受密码保护的文件 [英] Unzip a password protected file in vbsript
问题描述
我在这里遇到了麻烦,您能告诉我如何在 vbscript 中解压缩受密码保护的字段吗?我有一个完美运行的代码,但每次运行时都会询问密码
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!!
推荐答案
AFAIK Shell.Application
对象不支持提供密码.试试 7-zip:
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
如有必要,添加 7za.exe
和/或 file.zip
的路径.如果路径包含空格,您还需要在其周围加上双引号,例如像这样:
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")
这篇关于在 vbsript 中解压缩受密码保护的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!