我正在研究vbscript,一个接一个地解压缩多个文件。
我正在使用以下代码
Dim folder(3)
folder(0) = "UBO90R1"
folder(1) = "UBO90R2"
folder(2) = "UBO100R1"
folder(3) = "UBO100R2"
For i = 0 To 3
unzip_Source = "D:\Autobackup\" & folder(i) & ".zip"
unzip_destination = "D:\Autobackup_unzip\" & folder(i) &"\"
Call ExtractFilesFromZip(unzip_Source,unzip_destination)
WScript.Echo "unzip Finished"
Next
Sub ExtractFilesFromZip(pathToZipFile, dirToExtractFiles)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
pathToZipFile = fso.GetAbsolutePathName(pathToZipFile)
dirToExtractFiles = fso.GetAbsolutePathName(dirToExtractFiles)
If (Not fso.FileExists(pathToZipFile)) Then
WScript.Echo "Zip file does not exist: " & pathToZipFile
Exit Sub
End If
If Not fso.FolderExists(dirToExtractFiles) Then
WScript.Echo "Directory does not exist: " & dirToExtractFiles
Exit Sub
End If
dim sa : Set sa = CreateObject("Shell.Application")
Dim zip : Set zip = sa.NameSpace(pathToZipFile)
Dim d : Set d = sa.NameSpace(dirToExtractFiles)
d.CopyHere zip.items, 4
Do Until zip.Items.Count <= d.Items.Count
WScript.Sleep(200)
Loop
End Sub
当前存在的问题是,如果该文件夹或文件已经存在,那么它会向用户打开对话框以选择“覆盖,保留两个文件等”任何选项。
如果我从代码中更改了以下行
d.CopyHere zip.items, 4
'Integer 4 didn't show the progress bar
到
d.CopyHere zip.items, 16
'Integer 16 overwrite the existing file but it shows the progress bar.
我想在没有任何对话框和进度条的情况下覆盖现有文件。
PS:要解压缩从here复制的代码。
答案 0 :(得分:1)
如果您寻求帮助,它会告诉您的。
https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_shfileopstructa
_mm512_stream_pd