脚本解压缩受密码保护的文件

时间:2013-07-16 18:42:09

标签: vbscript

我有1000个zip文件要提取,这是受pswd保护的。每次它读取.zip文件并询问每个文件的pswd。每个文件的pswd是相同的。因此我需要迭代应该只询问一次。这段代码在XP中运行得很好,但现在在wondows7中它要求用于evry文件的pswd。

PLs帮助..............

 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

0 个答案:

没有答案