I am now working on a different organization that uses WSH. One task that really challenge me is to create a script that will save files to a zip file using Windows XP/2003 default compressor. Since I am previously using VBScript, its now really hard for me to adapt in using WSH.

Here is the script that I use for saving files to a zip file:

Const MyZip = “C:\test.zip”
Const File1 = “C:\Data\test1.txt”
Const File2 = “C:\Data\test2.txt”
‘————– create empty zip file ———
CreateObject(“Scripting.FileSystemObject”) _
.CreateTextFile(MyZip, True) _
.Write “PK” & Chr(5) & Chr(6) & String(18, vbNullChar)
‘————– zip the files ——————
With CreateObject(“Shell.Application”)
‘add files
.NameSpace(MyZip).CopyHere File1
.NameSpace(MyZip).CopyHere File2
End With
wScript.Sleep 1000

Thanks to LJ who replied this script. See thread.

About these ads