ZIP and UNZIP with VBScript on Windows XP

  • Thread starter Thread starter Guest
  • Start date Start date
[Alain Arsenault] wrote-:
Hi

Anyone know how to zip and unzip files with vbscript on windows XP ?


To UnZip files-
'----------------------------
pathToZipFile="C:\index.zip"
extractTo="C:\"

set sa = CreateObject("Shell.Application")
set filesInzip=sa.NameSpace(pathToZipFile).items
sa.NameSpace(extractTo).CopyHere(filesInzip)
'----------------------------

To Zip files-
'----------------------------
FolderToZip = "C:\CygWin"
zipFile = "C:\some.zip"

set sa = CreateObject("Shell.Application")
Set zip= sa.NameSpace(zipFile)
Set Fol=sa.NameSpace(FolderToZip)
zip.CopyHere(Fol.Items)
WScript.Sleep 2000 ' increase this if the folder is large
'----------------------------

Good Luck, Ayush.
 
Thanks

It's exactly what I was looking for. It is working very well.

Ayush" <"ayushmaan.j[aatt]gmail.com said:
[Alain Arsenault] wrote-:
Hi

Anyone know how to zip and unzip files with vbscript on windows XP ?


To UnZip files-
'----------------------------
pathToZipFile="C:\index.zip"
extractTo="C:\"

set sa = CreateObject("Shell.Application")
set filesInzip=sa.NameSpace(pathToZipFile).items
sa.NameSpace(extractTo).CopyHere(filesInzip)
'----------------------------

To Zip files-
'----------------------------
FolderToZip = "C:\CygWin"
zipFile = "C:\some.zip"

set sa = CreateObject("Shell.Application")
Set zip= sa.NameSpace(zipFile)
Set Fol=sa.NameSpace(FolderToZip)
zip.CopyHere(Fol.Items)
WScript.Sleep 2000 ' increase this if the folder is large
'----------------------------

Good Luck, Ayush.
 
Back
Top