문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top