VBScript Basics, Part 54 | Unzip – Extract Compressed Files


VBScripting (.vbs) Basic Tutorial On How-To:
Extract all of your compressed files.

Code Example:
******************

Option Explicit
Dim objFSO : Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Dim objAPP : Set objAPP = CreateObject(“Shell.Application”)
Dim COMP : COMP = “C:UsersJeremyDesktopTest.zip”
Dim EXTR : EXTR = Left(COMP, InStrRev(COMP,”.”) – 1)

If Not objFSO.FolderExists(EXTR) then
objFSO.CreateFolder EXTR
End If

objAPP.NameSpace(EXTR).CopyHere(objAPP.NameSpace(COMP).Items)

******************

Option Explicit
Dim objSHL : Set objSHL = WScript.CreateObject (“WScript.shell”)
Dim ZippedFile, ExtractTo
ZippedFile = “C:UsersJeremyDesktoptestzipfile.7z”
ExtractTo = “C:UsersJeremyDesktoptestfolder”

‘objSHL.Run “””C:Program FilesWinRarWinRar.exe”” x “&ZippedFile&” -o”&ExtractTo,0,True

objSHL.Run “””C:Program Files-Zipz.exe”” x “&ZippedFile&” -o”&ExtractTo,0,True