Uninstall is still running after installer exits - nsis

I am not sure how to put this here, I will do my best. Please help me out
I have a patch installer, which installs and uninstalls as expected. But after uninstalling the patch from program files, I have tried uninstall other software. All I got a pop message saying that let the uninstall finish uninstalling.
All I figured out is at the end of uninstalling my patch, I am starting a process by executing .exe file. My uninstaller waits for that process to quit, which I do not want to quit.
Other option I have is to force the user to reboot after uninstalling the patch, which I do not wish to do.
I tried Exec, ExecDos, and ExecCmd with /ASYNC, but I still see the same problem.
Try 1
ExecShell open "$INSTDIR\system\teven.exe"
Try 2
ExecDos::exec /NOUNLOAD /ASYNC "$INSTDIR\system\teven.exe" ""
Pop $0
ExecDos::isdone /NOUNLOAD $0
Can anyone help me to solve this. How can I start teven.exe and left it running and make my uninstaller not waiting teven.exe to quit.

You pretty much have to force the uninstaller to wait if you are going to do other things after the uninstaller completes. When you uninstall from Add/Remove programs Windows even forces a wait for all your child processes started by the uninstaller...
Why are you using /ASYNC if you want to wait? (Edit: I guess you don't want to wait?) ExecDos::isdone does not wait, it just checks, use ExecDos::wait if you want to wait.
If you are not using advanced options and don't need stdin input then you don't really need to use 3rd-party plugins:
If teven is a console application and you want to hide the console window (and wait):
nsExec::Exec '"$INSTDIR\system\teven.exe"'
otherwise:
ExecWait '"$INSTDIR\system\teven.exe"'
If you actually don't want to wait you can just use Exec but Windows might force a wait anyway when uninstalling...

Related

Is there any way to free the executable and it's dependencies after using it with Exec in NSIS

To free the DLL we are using "?u" like as shown below when we are Calling the DLL.
System::Call "Launch.dll::IsDriverPresent() i.r0 ?u"
Similarly Is there any way to free or unload the exe and it's dependencies after it used?
Because sometimes after uninstallation in the installed directory executable and its dependencies are still present.
Below is the line we are using to call Exec:
Exec '"$INSTDIR\ValidateDriver.exe" ON'
No you cannot unload a .EXE. A .EXE will be locked until its final thread ends and all handles to all threads and the process itself have been closed.
If you Kill/Terminate the process and it is still locked then most likely there is some Anti-Virus software still holding a lock on the file.
You can call Delete and Sleep in a loop and after 10 seconds or so of retrying you might have to just give up or display a MessageBox to the user.

Inno Setup Exec doesn't wait for InstallShield uninstallation to complete

Trying to uninstall a software using the uninstall string (and running that with Exec in InitializeSetup) before installation, it doesn't wait for the un-installation to complete but proceeds to the next step of installation in Inno Setup.
I am using the following code and the software I am trying to un-install in an Installshield product:
Exec(
ExpandConstant('{pf}\InstallShield Installation Information\{{XXX8X88X-XX8X-88X8-X8XX-88X888X88888}\setup.exe'),
'-s -runfromtemp -l0x0004 -removeonly -remove', '',
SW_SHOW, ewWaitUntilTerminated, ReturnCode)
The setup.exe most probably executes a subprocess for an actual uninstallation and exits itself. So Inno Setup seemingly does not wait for the process to finish. This is a common behavior, as the uninstaller needs to delete itself, what it cannot do, if it still running. So it creates a copy of itself (or another executable) in a temporary folder and (re)executes from there.
As per InstallShield documentation, you can try adding /w or /Clone_wait switches to the command-line:
/w ... For a Basic MSI project, the /w option forces Setup.exe to wait until the installation is complete before exiting.
/Clone_wait ... This parameter indicates that the original setup should wait for the cloned setup process to complete before exiting.

Open File during Installation

I am using NSIS to create installer. Also I need to install other program (I have his installation file). How add second installer to automatically run it during first installation?
The simplest is to run the file (which must be first extracted to some directory,. e.g. $TEMP) with
ExecShell "open" "$INSTDIR\app.exe"
or with
ExecWait '"$INSTDIR\someprogram.exe"' $0
if you want to wait for program to finish.
Also consider many possibilities: whether the app should be run with some parameter, in Silent mode or elevated with admin rights or run as original user...

How to set the whole installer invisible while using 'ExecWait' in NSIS?

I'm installing a program with my installer and run it with 'ExecWait'.
Is there a way to hide the window of the installer while the program is executed?
The installer should show up again and continue when the user quits the executed program.
Is there any way to achieve that?
HideWindow
ExecWait '"$InstDir\Foo.exe" "space bar" /baz'
BringToFront

NSIS script help-install without killing explorer

When I tried to un-install and install an executable foo.exe, Im geting the below error
Error opening file for writing
click abort to stop the installation
I could find that some files were failed to get deleted while un-installation.
And by using process explorer I can see that explorer.exe has still reference to some dlls of foo.exe even after unregistering them.
and killing the explorer.exe and re-start it again while un-installation solves the issue. (thru NSIS installation script).
or by setting rebook ok flag in script and ask user to re-start his machine before installing foo.exe again.
I don't think its a good solution to ask user to reboot his machine after un-installation .
Can anyone help me on how can I make sure that my installation goes fine instead of restarting explorer.exe
For registered shell extensions there is really no clean way to delete the dll's other than forcing a reboot (Or log-off if they are registered in HKCU\Software\Classes)
If that is not good enough you basically have two options:
Rename the .dll and delete it later
<HACKALERT>Inject a thread that calls CoFreeUnusedLibraries() into every process that has your dll loaded</HACKALERT>
Just killing and restarting explorer is not really an option since you don't know if some other program is also using your shell extension.

Resources