Search code examples
batch-filewindows-8cmdwindows-8.1unzip

Windows batch script to unzip files on Windows8/8.1


By default, all the zipped files in Windows 8/8.1 are configured to open with the File Explorer program that the operating system has. I want to unzip all files in a certain directory and preserve the folder names when unzipped using batch script. I know how to do this when 7-Zip installed on the machine. But how to do this on Windows 8/8.1 when no extracted software installed? I want to do this using windows script.


Solution

  • I found the way to do it using vbscript. Here is the code.

    strZipFile = ""                                       'name of zip file
    outFolder = ""                                       'destination folder of unzipped files
    
    Set objShell = CreateObject( "Shell.Application" )
    Set objSource = objShell.NameSpace(strZipFile).Items()
    Set objTarget = objShell.NameSpace(outFolder)
    intOptions = 256
    objTarget.CopyHere objSource, intOptions
    

    Fill in the appropriate names for the zip file and the output folder (must be quoted). Save the script with a vbs extension. In the batch file we can run the script with this entry: cscript //nologo scriptname.vbs