Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unzip a file in VBScript using internal Windows XP options in

I want to unzip a .zip file using VBScript, only it's always a new computer with no external applications on it. Now I know Windows XP and 2003 have an internal .zip folder option, so I guess I can use it via VBScript in order to extract the file.

How do I do it?

I tried:

Set objShell = CreateObject("Shell.Application")

Set SrcFldr = objShell.NameSpace(fileName)
Set DestFldr = objShell.NameSpace(appDir)
DestFldr.CopyHere(SrcFldr) 

Which didn't work. What could be the problem?

like image 448
aviv Avatar asked May 26 '09 14:05

aviv


1 Answers

Just set ZipFile = The location of the zip file, and ExtractTo = to the location the zip file should be extracted to.

'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
like image 139
Tester101 Avatar answered Oct 15 '22 21:10

Tester101