I have created an .exe file containing a test.zip file and a extract.bat file. I am trying to configure the extract.bat file so that it can extract the test.zip to C:\Temp folder.

The bat file looks like this :

echo off
cd /d %~dp0
Call :UnZipFile "C:\Temp\" **for /F %%I IN ('dir /b /s *.zip)**
exit /b

:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs%  echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%

I am confused and to be honest not sure if I am doing it correctly.It does not work. My challenge is I am unable to declare the location of the .zip file as both the test.zip file and the extract.bat file would be a part of the same .exe file. Also, I am using Iexpress.exe to create the .exe file. Any help would be much appreciated. Thanks in advance.


If the extract script is part of the exe file, just make a self-extracting executable which would self-extract itself in a specified location. (This is the object-oriented approach, by the way: you tell the exe archive to unpack itself ;) IExpress is only one of available options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.