[英]Inno Setup Script - running exe before installing
I wanna run an application before installing and I'm using this code on Inno Setup Script(Pascal): 我想在安装之前运行一个应用程序,我在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. 当我使用“{win} \\ notepad.exe”时,它可以工作但是当我使用“{src} \\ MyFolder \\ Injector.exe”时,安装程序不会打开我的程序并继续安装。
Note : Injector has app.manifest which has 'requireAdministrator'. 注意:Injector的app.manifest有'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. 在代码中使用
{src}
等值时,需要使用ExpandConstant
函数。
However, InitializeSetup
is also too early to run installation tasks. 但是,
InitializeSetup
还为时过早,无法运行安装任务。 You should move this code into CurStepChanged(ssInstall)
. 您应该将此代码移动到
CurStepChanged(ssInstall)
。
Also, if it requires admin permissions it must be run with Exec
, not ExecAsOriginalUser
. 此外,如果它需要管理员权限,则必须使用
Exec
而不是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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.