简体   繁体   English

如何执行另一个NSIS安装程序并等待它完成?

[英]How to execute another NSIS installer and wait for it to finish?

I'm writing an installer in NSIS, which is kind of a wrapper for another installer, created with NSIS. 我正在NSIS中编写一个安装程序,它是使用NSIS创建的另一个安装程序的包装器。 The inner installer is not mine. 内部安装者不是我的。 It's created with BioWare Installer 1.03 (NSIS 2.34). 它是用BioWare Installer 1.03(NSIS 2.34)创建的。 It may be broken somehow, but I can't modify it! 它可能会以某种方式被破坏,但我不能修改它! What my installer does is that it simply modifies some registry values (otherwise the "inner" installer won't run), then executes the installer, then overwrites some files and then restores the previous registry values. 我的安装程序所做的是它只是修改了一些注册表值(否则“内部”安装程序将不会运行),然后执行安装程序,然后覆盖一些文件,然后恢复以前的注册表值。

My problem: I have no idea how to actually wait for the "inner" installer to finish! 我的问题:我不知道如何实际等待“内部”安装程序完成! It's because the installer first unpacks it's content and creates a new process, which is the real installer. 这是因为安装程序首先解压缩它的内容并创建一个新进程,这是真正的安装程序。 And the code executes as soon as the first process (unpacking) finishes. 一旦第一个进程(解包)完成,代码就会执行。 Waiting is crucial here, because I need to overwrite some files. 等待在这里至关重要,因为我需要覆盖一些文件。

I have read this: http://nsis.sourceforge.net/When_I_use_ExecWait,_it_doesn't_wait , but I can't find any switches for NSIS installer. 我读过这个: http//nsis.sourceforge.net/When_I_use_ExecWait,_it_doesn't_wait ,但我找不到NSIS安装程序的任何开关。

I have tried ExecWait and nsExec::Exec, but none of them waits for the real installer, just for the first process to finish. 我已经尝试过ExecWait和nsExec :: Exec,但是没有一个等待真正的安装程序,只是为了完成第一个进程。

First off, I have never seen ExecWait fail, but it will only wait for a child process, not the child of that child process. 首先,我从未见过ExecWait失败,但它只会等待子进程,而不是那个子进程的子进程。 So every process in the chain needs to wait for its child. 因此,链中的每个过程都需要等待它的孩子。 If the "middle" process is broken, try http://nsis.sourceforge.net/ExecWait_and_waiting_for_child_processes_with_Job_Objects 如果“中间”过程被破坏,请尝试http://nsis.sourceforge.net/ExecWait_and_waiting_for_child_processes_with_Job_Objects

For ExecWait, the tree would look like: 对于ExecWait,树看起来像:

  • NSIS1.exe: ExecWait NSIS2.exe NSIS1.exe:ExecWait NSIS2.exe
    • NSIS2.exe: ExecWait RealSetup.exe NSIS2.exe:ExecWait RealSetup.exe
      • RealSetup.exe: ... RealSetup.exe:...

Your description is a little unclear, can you confirm that I got the general idea? 你的描述有点不清楚,你能证实我有一般的想法吗?

If you could not find the switches for NSIS it means you did not RTFM :) 如果你找不到NSIS的开关,这意味着你没有RTFM :)

Found this question because I was having a similar issue. 发现这个问题是因为我遇到了类似的问题。 In my NSIS installer, I was downloading a Microsoft Visual Studio exe file, and attempting to install it first (to get some dependency dll files). 在我的NSIS安装程序中,我正在下载Microsoft Visual Studio exe文件,并尝试首先安装它(以获取一些依赖dll文件)。 However, this never worked: 但是,这从未奏效:

ExecWait "$TEMP\vcredist_x86.exe"

It just skipped right over -- I suspect because of the issue with child processes (maybe? The MS installer was interactive and would ask the user to accept a license). 它只是跳过了 - 我怀疑是因为子进程的问题(可能?MS安装程序是交互式的并且会要求用户接受许可证)。 I wound up using ExecShellWait instead: 我最后使用ExecShellWait

ExecWaitShell "open" "$TEMP\vcredist_x86.exe"

And then my installer would properly wait for the third-party installer to finish, before moving on. 然后我的安装程序将正确等待第三方安装程序完成,然后再继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM