【问题标题】:Inno Setup installer cannot run application just installed by child installer (Unable to run Node. Create process failed)Inno Setup 安装程序无法运行子安装程序刚刚安装的应用程序(无法运行节点。创建进程失败)
【发布时间】:2018-05-03 08:54:04
【问题描述】:

我已经编写了脚本来安装 Node.js,使用 Inno Setup 运行 shell 脚本和 Windows 服务。我已经创建了一个设置。当我安装我的安装程序时,Node.js 会成功安装。

[Run]    
Filename: "msiexec.exe"; Parameters: "/i ""{app}\nodejs\node-v8.11.1-x64.msi""";

Shell 脚本运行成功。

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
  ErrorCode: Integer;
  ReturnCode: Boolean;
begin
  ExtractTemporaryFile('Add-AppDevPackage.ps1');
  ReturnCode :=
    ShellExec('open', '"PowerShell"',
    ExpandConstant(' -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden  -File "{app}\setup\Add-AppDevPackage.ps1"'),
    '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);

    if (ReturnCode = False) then
        MsgBox('Message about problem. Error code: ' + IntToStr(ErrorCode) + ' ' + SysErrorMessage(ErrorCode),
          mbInformation, MB_OK);
end;

但是当我尝试运行一个 .js 文件 (installservice.js) 的 Windows 服务时,我会收到类似的错误

无法运行节点。创建进程失败代码2。

用于运行节点的代码:

[Run]
Filename: "node"; Parameters: "installservice.js"; WorkingDir: "{app}\nodepath"; \
    Flags: nowait postinstall skipifsilent runascurrentuser; AfterInstall: MsbShow;

而且我还发现如果机器中已经安装了Node JS,那么Windows 服务会完美安装并运行。我不知道错误在哪里。我什至尝试在安装后运行 Windows 服务,但问题仍然存在。你能指导我完成这个过程吗?

【问题讨论】:

    标签: node.js inno-setup pascalscript


    【解决方案1】:

    您的[Run] 条目依赖于nodePATH 中。

    如果您刚刚安装了 Note.js,则不会出现这种情况,因为 Node.js 安装程序对 PATH 的更改不会反映在已运行的进程中(尤其是您的 Inno Setup 安装程序)。

    您必须在运行程序之前显式重新加载环境。

    [Run]
    Filename: "node"; BeforeInstall: RefreshEnvironment; ...
    

    RefreshEnvironment 实现显示在:
    Environment variable not recognized [not available] for [Run] programs in Inno Setup


    当然,您也可以使用node 的绝对路径。但是你要么必须依靠 Node.js 安装程序将 Node.js 安装到标准位置(我在这里猜测路径,我不知道 Node.js):

    [Run]
    Filename: "{pf}\Node.js\node"; ...
    

    (可能不可靠)。

    或者您必须以编程方式检测安装位置,在这种情况下,上述RefreshEnvironment 解决方案将更易于实施。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-06
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      相关资源
      最近更新 更多