How to extract a zip file with vbscript

Written by steve diamond
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to extract a zip file with vbscript
Extract a ZIP file with VBScript. (black zipper pull image by robert mobley from

When Microsoft released the current generation of its Windows Script Host in 2002, it made available to developers and system administrators a powerful and flexible scripting environment. Combined with an object model accessible in WSH that lets programmers automate some of the built-in functionality of the Windows operating system, VBScript, also known as Visual Basic Scripting Edition, can perform simple tasks with just a few lines of code. Because Windows since XP has included native support for compressing and extracting zip files, a short VBScript script can extract the contents of a zip file into a folder.

Skill level:


  1. 1

    Click "Start", "All Programs", "Accessories", "Notepad" to open Windows Notepad.

  2. 2

    Copy and paste the following VBS code into the Notepad window:

    Function Unzip(strFileName,strFolderName)

    Dim objshell

    Dim objfso

    ' Create Shell.Application so we can use the CopyHere method

    Set objshell = CreateObject("Shell.Application")

    ' Create FileSystemObject so we can use FolderExists and CreateFolder if necessary

    Set objfso = CreateObject("Scripting.FileSystemObject")

    ' Create folder to receive files if it doesn't already exist

    If Not objfso.FolderExists(strFolderName) Then objfso.CreateFolder strFolderName

    ' Use CopyHere to extract files

    objshell.NameSpace(strFolderName).CopyHere objshell.NameSpace(strFileName).Items

    Set objfso = Nothing

    Set objshell = Nothing

    End Function

    Put your own zip file name and folder name inside the quotes in the next line

    Unzip "C:\Test\","C:\Test\Testing"

  3. 3

    Edit the last line to substitute your own zip file name and folder name for the examples given inside the quotation marks. You can specify an existing folder or not. The script will create the folder if it doesn't already exist.

  4. 4

    Click "File", "Save As" to open the Save As dialogue window. Type "extractzip.vbs" (without the quotes) in the "File Name" box. Select "All Files (.)" from the "Save As Type" drop-down. Click the "Save" button to save the new VBS file.

  5. 5

    Click "Start", "Documents" to open a Windows Explorer window. Navigate to the folder where you saved the VBS file in Step 4. Double-click extractzip.vbs to run the script and extract the zip file into the specified folder.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.