2
votes

I have an issue with the Inno Setup uninstaller. I have a exe file I want to executable to keep track of the installation and uninstallations. The exe is really simple and sends a message to a server.

[Files]
Source: "Tracker\LocalSandboxInstallTracker.exe"; DestDir: "{app}/Tracker";
Source: "Tracker\LocalSandboxInstallTracker.exe.config"; DestDir: "{app}/Tracker";
Source: "Tracker\Tracker.Client.dll"; DestDir: "{app}/Tracker";

[Run]
Filename: "{app}\Tracker\LocalSandboxInstallTracker.exe"; Parameters: " {#MyAppVersion} install"; Flags: runhidden; StatusMsg: "Sending tracking data..."

[Code]
procedure InitializeUninstallProgressForm();
var
  ResultCode: Integer;
begin
  Exec ('{app}\Tracker\LocalSandboxInstallTracker.exe',' {#MyAppVersion} uninstall','',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;

The call at the installation works well, but not at the uninstall. I placed a breakpoint to my Exec command and it really goes through there, but the exe does not seem to be called.

2
What returns the Exec function, True or False ? What's the value of the ResultCode after this call ? - TLama
The ResultCode is 0 before the Exec, and 267 after. - Amaranth
You do realize that the app is going to trigger malware/spyware software and firewalls, right? And that the fact you're doing so with runhidden looks very suspicious? I for one would advise people not to install it, because it looks like possibly malicious behavior. - Ken White

2 Answers

5
votes

You must expand the {app} constant before passing it to the Exec script function. Use the ExpandConstant whenever you need to get the value of the constant. Modify your script this way:

Exec(ExpandConstant('{app}\Tracker\LocalSandboxInstallTracker.exe'), 
  '{#MyAppVersion} uninstall', '', SW_SHOW, 
  ewWaitUntilTerminated, ResultCode);

Also, you should check the function result and the output result code to react when the Exec function fails. The error code you'll get in the ResultCode you can check against the System Error Codes reference or use SysErrorMessage(ResultCode) to get the error description from script.

4
votes

You have to call the ExpandConstant function if you want to use constants like {app} in your Exec call:

[Code]
procedure InitializeUninstallProgressForm();
var
  ResultCode: Integer;
begin
  Exec (ExpandConstant('{app}\Tracker\LocalSandboxInstallTracker.exe')
    ,' {#MyAppVersion} uninstall','',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;

Other way, you're failing to locate the exe.