Compress a folder (VBScript)

This code can be found in Chapter 8 of Windows XP Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Windows XP Cookbook"
' ISBN: 0596007256

' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strFolder = "<FolderPath>" ' e.g. d:\scripts
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objFolder = objWMI.Get("Win32_Directory='" & strFolder & "'")
intRC = objFolder.Compress ' To uncompress change this to objFolder.Uncompress
if intRC <> 0 then
 WScript.Echo "There was an error compressing the folder: " & intRC
else
 WScript.Echo "Folder compression successful"
end if

This code has been viewed 1794 times.

New from the creators of TechTasks.com: StatSheet.com