Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > Files > CAB Files

CAB Files

  1. Create CAB files with MakeCab
  2. Extract CAB files with System.Shell Folders' CopyHere method

 

MakeCab
VBScript Code:
CabCreate "D:\test.cab", Array( "D:\test.bat", "D:\Test.pdf" )

Sub CabCreate( myCabFile, arrFiles )
' This function creates a CAB file and adds a
' number of files from an array to the CAB file.
'
' Arguments:
' myCabFile    The fully qualified path for the CAB file to be created
' arrFiles     An array of fully qualified paths of the files to be added
'
' Requirements:
' MakeCab requires .NET FrameWork 2.0 or later
'
' Based on a script by Rinaldo Ferreira
' http://www.codecomments.com/archive299-2006-1-783560.html
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
    Dim i, objCab, objFSO
    Set objFSO = CreateObject( "Scripting.FileSystemObject" )
    Set objCab = CreateObject( "MakeCab.MakeCab.1" )
    ' CStr() is necessary, because MakeCab object
    ' only accepts string arguments, not variants
    objCab.CreateCab CStr( myCabFile ), False, False, False
    For i = 0 To UBound( arrFiles )
        objCab.AddFile CStr( arrFiles(i) ), _
                       CStr( objFSO.GetFileName( arrFiles(i) ) )
    Next
    objCab.CloseCab
End Sub
Requirements:
Windows version: 2000, XP, Server 2003, or Vista
Network: any
Client software: .NET FrameWork 2.0
Script Engine: any
Summarized: Works in Windows 2000 or later with .NET FrameWork 2.0 or later installed.
 
[Back to the top of this page]

page last modified: 2016-09-19; loaded in 0.0062 seconds