2

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; 
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks for the response ! I couldnt paste my code snippet here in the comments section. Hence, have posted an answer seeking some clarification. – Roshan Shiveshwar Jun 10 '19 at 12:11
  • `ExtractTemporaryFile('{#MyAppExeName}');` and `ExpandConstant('{tmp}\{#MyAppExeName}')` instead of `ExpandConstant('{tmp}\{#MyAppExeName}') ` worked for me. Thanks ! – Roshan Shiveshwar Jun 11 '19 at 05:28