Search code examples
batch-fileinstallationiexpress

how to run batch file after installing all files (IExpress)


so I have 2 files, a zipped file with all my files/folders for a game and a unzipper.bat file that puts everything in the correct place to work.

I decided to use IExpress to make an installer for my game, and there was an option for running a file on installation, so i put setup.bat there thinking that it would run when all the files were installed, but it didnt do that.

how can I make it so that it runs setup.bat ones all the files have been installed?

edit: this i my current SED file

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=1
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=I
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=Are you sure you want to install Block Dodger?
DisplayLicense=
FinishMessage=Thank you for installing Block Dodger.
TargetName=C:\Users\Gebruiker\Desktop\Block Dodger (installer).EXE
FriendlyName=Block Dodger installer
AppLaunched=cmd.exe /c unzipper.bat
PostInstallCmd=%SystemRoot%\System32\cmd.exe /C unzipper.bat
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="Block_Dodger.zip"
FILE1="unzipper.bat"
[SourceFiles]
SourceFiles0=C:\Users\Gebruiker\Desktop\
[SourceFiles0]
%FILE0%=
%FILE1%=

when i run the installer it gives the following error: error

the batch file which couldnt be found (shortcut_creator.bat) is in the zipped file unzipper.bat is supposed to unzip.

this is the content of unzipper.bat:

@echo off
setlocal
cd /d %~dp0
Call :UnZipFile "%~dp0" "%~dp0Block_Dodger.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%

del /f /q "%~dp0Block_Dodger.zip"

start /d "%~dp0Block_Dodger" shortcut_creator.bat

edit 2: i just checked the box "Store files using Long Files names inside Package" and it does work now, the only thing left now is how do i change where the files end up?


Solution

  • In your SED file, the PostInstallCmdshould be set as :

    PostInstallCmd="%SystemRoot%\System32\cmd.exe /C setup.bat"