我有 1000 个要提取的 zip 文件,这些文件受 pswd 保护。每次它读取 .zip 文件并向 pswd 询问每个文件。每个文件的 pswd 都是相同的。因此我需要它应该只问一次。此代码在 XP 中运行良好,但现在在 wondows7 中,它要求为 evry 文件提供 pswd。
PL帮助........
pathToZipFile = "C:\Reco\SCRIPT\Filefinder\zip"
extractTo = "C:\Reco\SCRIPT\Filefinder\unzip"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(pathToZipFile)
Set fc = f.Files
Dim myZipFile
Dim intOptions, objShell, objSource, objTarget
Dim pwd
pwd = "cola"
For Each f1 in fc
On Error Resume Next
myZipFile = f1
' Create the required Shell objects
Set objShell = CreateObject( "Shell.Application" )
' Create a reference to the files and folders
'Set objSource = objShell.NameSpace(pwd+myZipFile).Items( )
Set objSource = objShell.NameSpace(myZipFile).Items( )
' Create a reference to the target folder
Set objTarget = objShell.NameSpace(pwd+extractTo)
Set objTarget = objShell.NameSpace(extractTo)
Set sh = CreateObject("WScript.Shell")
sh.Run "7za.exe x " & myZipFile & " -p" & pwd, 0, True
intOptions = 256
' UnZIP the file
objTarget.CopyHere objSource, intOptions
' Release the objects
Set objSource = Nothing
Set objTarget = Nothing
Set objShell = Nothing
Next