Reputation: 33
I have created a simple executable (.exe) file using Inno Setup Compiler 6.0.2 for installing a Windows application.
The .exe file calls a vbscript "Setup.vbs" that unzips "Application.zip" file and updates environment variables.
When I run the .exe file for the first time on a new machine, the .vbs file doesn't get executed. But, from second attempt onwards it works fine. Is this a known issue or is there any solution for this?
Here is the code snippet that I am using to call run .vbs file
[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var ResultCode: integer;
begin
ShellExec('',ExpandConstant('{app}\{#MyAppExeName}'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
end;
I want the .vbs to execute before the installation. So, I tried ExtractTemporaryFile
, still I am facing the same issue. Not sure what is is wrong with the code below.
#define MyAppExeName "Setup.vbs"
[Files]
Source: "..\Application\Installation_Setup\Setup.vbs"; DestDir: "{app}"; Flags: ignoreversion
[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: integer;
begin
ExtractTemporaryFile('{#MyAppExeName}');
ShellExec('',ExpandConstant('{app}\{#MyAppExeName}'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
end;
Upvotes: 2
Views: 1598
Reputation: 202272
PrepareToInstall
happens before installation. As you execute a file that is installed, it does not exist yet at the time you call it.
Possible solutions
Execute the script after installation from CurStepChanged(ssPostInstall)
:
Code to run after all files are installed
Or you can use [Run]
section:
Executing installed batch file in Inno Setup
If you need to execute the script before installation (I do not think that's your case), use ExtractTemporaryFile
.
For extracting ZIP, you do not need VBS script, you can do that directly from Inno Setup code.
How to get Inno Setup to unzip a file it installed (all as part of the one installation process)
Upvotes: 1