tags:

views:

41

answers:

1

I'm writing an installer in NSIS, which is kind of a wrapper for another installer, created with NSIS. The inner installer is not mine. It's created with 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.

I have tried ExecWait and nsExec::Exec, but none of them waits for the real installer, just for the first process to finish.

A: 

First off, I have never seen ExecWait fail, but it will only wait for a child process, not the child of that child process. 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

For ExecWait, the tree would look like:

  • NSIS1.exe: ExecWait NSIS2.exe
    • NSIS2.exe: ExecWait 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 :)

Anders
Yes, that's the idea. What I need to run inside my installer (NSIS1.exe) is another installer created with NSIS (NSIS2.exe). The problem is that NSIS2.exe starts off with unpacking it's contents and after that it runs the RealSetup.exe. Most typical methods, like ExecWait return to code execution as soon as NSIS2.exe finishes unpacking, NOT waiting for completing the RealSetup.exe. I did RTFM :) The very same page you have linked, but as far as I can see, there are only THREE switches, none of which makes the installer wait for it child processes (like /SMS switch doesfor InstallShield).
Jakub Gocławski
I have just tried your solution with Job Objects. Unfortunately the code execution totally freezes after starting the NSIS2.exe. Technically, it waits for it's completion, but even after that - it doesn't continue my NSIS1.exe :) The code is far from human-readable, so debugging it would be a very difficult task. The best solution I have found so far is to display a MessageBox after ExecWait, asking the user to make sure NSIS2.exe (and RealSetup.exe) are finished. This successfully halts NSIS1.exe but it's still not a very nice solution.
Jakub Gocławski
Anders
My bad if I wasn't specific enough, sorry! I must have forgotten to mention that the second installer is NOT mine. The big picture is: several days ago BioWare released a DLC to one of their games (Mass Effect 2). It's not available in some countries, in which previous DLCs were available. But it works ok if you change one thing in your registry (language ID) and rename several files after installation. For typical user, that's usually too much, so he doesn't even bother buying the DLC. I'd like to create a wrapper for doing all this and help install the DLC.
Jakub Gocławski
As I can see the DLC Installer uses: "BioWare Installer 1.03 (NSIS 2.34)". But I can't modify it or look into the source code. There might be some errors, like the first unpacking process not waiting for it's child process - but I can't control that! I believe that if it was done in InstallShield, then I could change such behaviour with a specific switch. I don't know if the problem is even possible to solve in such situation :/ Thanks for your time, though! :)
Jakub Gocławski