如何使用内部Windows XP选项在VBScript中解压缩文件

avi*_*viv 14 windows vbscript scripting zip

我想使用VBScript解压缩.zip文件,只是它总是一台没有外部应用程序的新计算机.现在我知道Windows XP和2003有一个内部.zip文件夹选项,所以我想我可以通过VBScript使用它来提取文件.

我该怎么做?

我试过了:

Set objShell = CreateObject("Shell.Application")

Set SrcFldr = objShell.NameSpace(fileName)
Set DestFldr = objShell.NameSpace(appDir)
DestFldr.CopyHere(SrcFldr) 
Run Code Online (Sandbox Code Playgroud)

哪个没用.可能是什么问题呢?

Tes*_*101 32

只需设置ZipFile = zip文件的位置,并将ExtractTo =设置为zip文件应提取到的位置.

'The location of the zip file.
ZipFile="C:\Test.Zip"
'The folder the contents should be extracted to.
ExtractTo="C:\Test\"

'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
Run Code Online (Sandbox Code Playgroud)

  • 在JScript中编写相同内容时,需要注意转义反斜杠("\\").那个让我头疼的问题. (2认同)