我在VBScript中编写了以下代码,首先提取zip文件的名称,然后在给定的文件夹中提取相同的文件,但是我收到了错误。
strFolder = "C:\Users\Desktop\tf\"
Dim aFileNameSize(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colFolder = objFSO.GetFolder(strFolder)
Set colFiles = colFolder.Files
For Each strFile In colFiles
aFileNameSize(0) = strfile.Name
strFileName = aFileNameSize(0)
Next
'The location of the zip file.
ZipFile = "C:\Users\Desktop\tf\strFileName"
'The folder the contents should be extracted to.
ExtractTo = "C:\Users\Desktop\tf\UNZIP\"
'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(ExtractTo) Then
fso.CreateFolder(ExtractTo)
End If
'Extract the contants of the zip file.
Set objShell = CreateObject("Shell.Application")
Set FilesInZip = objShell.NameSpace(ZipFile).Items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing
这是一个错误说
所需对象:objshell.NameSpace( - )
注意:我编写了单独的代码来解压缩并提取名称,并且它的工作非常正常。