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:
Other People Are Reading
Click "Start", "All Programs", "Accessories", "Notepad" to open Windows Notepad.
Copy and paste the following VBS code into the Notepad window:
' 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
Set objfso = Nothing
Set objshell = Nothing
Put your own zip file name and folder name inside the quotes in the next line
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.
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.
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.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for