Archive: Uninstall runs but doesn't delete open programs


Uninstall runs but doesn't delete open programs
Does anyone know of a way to help nsis deal with open programs during the uninstall process?

If the application installed by our nsis installer is open when the uninstaller is run, then the uninstaller completes without error, but the application.jar file that was open is left behind and the application is still running.

If I try to manually delete the jar file while the application is running I get a window pop-up that says:

"Cannot delete application: It is being used by another person or program. Close any programs that might be using the file and try again."

I would like to have nsis pop-up a message like this when it tries to uninstall an open program, rather than skipping it and claiming that all is well.

Alternatively, nsis could kill the application before uninstalling, but as the application is a jar file the Windows Task Manager and wmic commands simply shows the process as "javaw.exe" which makes it hard to kill since there may be other java applications running on the user's machine.

This problem occurs on XP and Windows7 (at a minimum). Any help will be appreciated.

Jay


You can try a executable wrapper for Java. First two results are for JSmooth and j4launch.

http://jsmooth.sourceforge.net/
http://launch4j.sourceforge.net/

That should allow you to identify your program and kill it/or ask the user to close it first.


You have two options that I can think of:

1. Use the LockedList plug-in to either show its dialog or use the IsFileLocked function to test if your files are locked.
2. Simply use the /rebootok switch on your Delete instructions thus requiring the user to reboot.

Stu


Personally, I use nsisDDE to send a Dynamic Data Exchange (DDE) message to my application to ask it to exit by itself.
This is possible with the applications that implements a DDE server with an Exit or Quit function (like Microsoft apps and probably others, or it's easy to do if you code the application under MFC)
This way, the application exits smoothly, saving its state or even asking the user, rather than forcibly kill the running application.

I don't know if it solves your specific request however, as your program is under Java.
(Looking on Google, there are a few DDE wrappers for Java available)


So I was able to implement the LockedList plugin fairly easily and my installer now checks for the appropriate locked file on both install and uninstall. The problem I have now is that during the uninstall the LockedList plugin consistantly misses the locked file when initially run. If I say next, then back to get to the LockList plugin again, it searches for and finds the locked file which is definitely there. When I then kill the application, LockList correctly updtes and states that no files are open.

Any ideas as to why it would lie on the first attemp?

Jay


Some basic code that reproduces the issue would be helpful.

Stu


Stu,

Here is the code I was using:

Function LockedListShow

!insertmacro MUI_HEADER_TEXT `Locked File Dialog` `Checking if the ${LINK_NAME} application is running. If so, it should be closed prior to running the installer.`

LockedList::AddFile "$INSTDIR\${PRODUCT_LINK}.jar"
LockedList::Dialog /ignore ``
Pop $R0

FunctionEnd

Function un.LockedListShow

!insertmacro MUI_HEADER_TEXT `Locked File Dialog` `Checking if the ${LINK_NAME} application is running. If so, it must be closed for the Uninstaller to run properly.`

LockedList::AddFile "$INSTDIR\${PRODUCT_LINK}.jar"
LockedList::Dialog /ignore ``
Pop $R0

FunctionEnd

Called via:

!insertmacro MUI_PAGE_WELCOME
;Page Custom LockedListShow
Page Custom LicensePage
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;UninstPage Custom un.LockedListShow
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

With a little more searching on the nsis forums I found the following:
http://nsis.sourceforge.net/Check_wh...uninstallation

This allowed me to correctly determine if the application is running and abort if true. This seems to work very well and doesn't allow the user to continue anyway which the LockedList seems to allow.

Thanks,

Jay


Using the /ignore switch allows the user to continue. I will put your bug on my TODO list.

Stu


Stu,

Thanks for the response.

Jay


I cannot reproduce the problem. Can you produce a buildable script for me?

This is the one I am using to test (attached).

Stu