2
votes

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;

Update

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; 
1
Thanks Andrew ! Being new to stackoverflow, having tough time posting code in comments.Roshan Shiveshwar

1 Answers

1
votes

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