Reputation: 1301
I wanna run an application before installing and I'm using this code on Inno Setup Script(Pascal):
function InitializeSetup():boolean;
var
ResultCode: integer;
begin
// Launch Notepad and wait for it to terminate
if ExecAsOriginalUser('{src}\MyFolder\Injector.exe', '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// handle success if necessary; ResultCode contains the exit code
end
else begin
// handle failure if necessary; ResultCode contains the error code
end;
// Proceed Setup
Result := True;
end;
When I'm using "{win}\notepad.exe", It works but when I use "{src}\MyFolder\Injector.exe", Setup doesn't open my program and continues install.
Note : Injector has app.manifest which has 'requireAdministrator'. However this application should be run as administrator.
So what's wrong?
Upvotes: 1
Views: 5164
Reputation: 10526
This May work for you... I believe that this problem is because of spaces in the entire path..that should overcome with double quoting the path...
Exec('cmd.exe','/c "'+ExpandConstant('{src}\MyFolder\Injector.exe')+'"', '',SW_SHOW,ewWaitUntilTerminated, ResultCode);
cheers..
Upvotes: 1
Reputation: 13095
You need to use the ExpandConstant
function when using values such as {src}
in code.
However, InitializeSetup
is also too early to run installation tasks. You should move this code into CurStepChanged(ssInstall)
.
Also, if it requires admin permissions it must be run with Exec
, not ExecAsOriginalUser
.
Upvotes: 3