Old 3rd January 2007, 23:51   #1
QMastor
Junior Member
 
Join Date: Jan 2007
Posts: 9
Silent uninstall will not abort if application is in use

I have an uninstaller that checks whether the application it is removing is currently in use (Using iceman_k's "FindProc" plugin), and is supposed to abort if it is.

When running the uninstaller normally, a custom page is displayed (Using the MUI) informing the user that they need to exit the application before continuing. This works as expected.

However, if the uninstaller is run silently, it should abort during the initialization phase. This is NOT working as expected. Every time I run the uninstaller silently, it will continue with the uninstallation process regardless of whether the application is currently in use or not.

The following is a simplified version of my uninstaller:

code:

!insertmacro MUI_UNPAGE_WELCOME
UninstPage CUSTOM un.ApplicationInUse_EnterPage un.ApplicationInUse_ExitPage
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH


Section "Uninstall"
; These instructions are reused by "onInstFailed"
!include "Uninstallation.nsi"

SetAutoClose TRUE
SectionEnd


Function un.onInit
IfSilent +3 0
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CustomPage.ini"
GoTo End

FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
${If} $R0 == 1
Abort
${EndIf}

End:
FunctionEnd


Function un.ApplicationInUse_EnterPage
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0

${If} $R0 == 1
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "CustomPage.ini"
${EndIf}
FunctionEnd


Function un.ApplicationInUse_ExitPage
Quit
FunctionEnd



Note that the "FindProc" call only returns a value of "1" if the application can definitely be determined to be in use.

So, the question is, what's the problem? The script being used in the "un.onInit" and "un.ApplicationInUse_EnterPage" functions is the same, yet only the latter works as expected.
QMastor is offline   Reply With Quote
Old 4th January 2007, 04:47   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
The code as it appears here seems correct.
Did you try to debug the silent return of FindProcDll with a message box? e.g.

Function un.onInit
IfSilent 0 end
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
MessageBox MB_OK '$$R0 == {$R0}'
${If} $R0 == 1
Abort
${EndIf}
End:
FunctionEnd

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 4th January 2007, 05:08   #3
QMastor
Junior Member
 
Join Date: Jan 2007
Posts: 9
Quote:
Originally posted by Red Wine
Did you try to debug the silent return of FindProcDll with a message box?
I was of the belief that MessageBoxes didn't display in Silent mode, and since no MessageBox was displayed when I tested your suggestion code, it looks like I may have been right...

Should the MessageBox be displayed when Silent mode is on, or is there another (Preferrably easy) way of outputting debug information?

Either way, I would hope that the plugin should behave the same way regardless of the uninstaller's "silence". I can't think of any reason why it shouldn't...?
QMastor is offline   Reply With Quote
Old 4th January 2007, 05:32   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
This doesn't work for you?

OutFile 'test.exe'

Section "boo"
call func
SectionEnd

function func
IfSilent +1 +2
Messagebox MB_OK 'We re running silent' idok end
Messagebox MB_OK 'poof'
end:
functionend

function .onInit
SetSilent silent
functionend

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 4th January 2007, 05:54   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
is there another (Preferrably easy) way of outputting debug information?
code:
Function un.onInit
FileOpen $0 '$EXEDIR\debug.txt' w
IfSilent 0 end
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
;MessageBox MB_OK '$$R0 == {$R0}'
FileWrite $0 'We re running silent$\r$\n'
FileWrite $0 '$$R0 == {$R0}$\n$\n'
FileClose $0
ExecShell open '$EXEDIR\debug.txt'
${If} $R0 == 1
Abort
${EndIf}
End:
FileWrite $0 'We re NOT running silent'
FileClose $0
ExecShell open '$EXEDIR\debug.txt'
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 4th January 2007, 21:55   #6
QMastor
Junior Member
 
Join Date: Jan 2007
Posts: 9
Previous attempts to make a MessageBox appear when running in Silent mode did not work, but recent ones did, so I'll lump that in with the other great mysteries of life for the time-being.

When I did eventually get my MessageBox, it indicated that the plugin was working as expected, so I started looking at other things.

One small change I tried, was changing the label used to direct program execution when it was determined that the uninstaller was running in Silent mode. Instead of a "+3", to skip over the extraction of a custom GUI page, I created a label just before the start of the "Silent mode" script, and explicitly named it. Strangely enough, it worked perfectly!

So, by changing the "un.onInit" function to this...

code:

Function un.onInit
IfSilent SilentMode 0
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CustomPage.ini"
GoTo End

SilentMode:
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
${If} $R0 == 1
Abort
${EndIf}

End:
FunctionEnd



...I got it working the way I had expected it to all along.

I have to admit that I've occassionally run into issues with numbered labels like this before, but this one definitely looked like it should have worked... Oh well.

Thankyou very much for your help anyway.
QMastor is offline   Reply With Quote
Old 5th January 2007, 03:21   #7
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
You're welcome!
You may want to refer to NSIS manual 4.9.4.15 MessageBox,
or accept living the life with those great "mysteries". :-)
BTW while studying the manual, you'll find useful info regarding to labels and relative jumps (numbered labels) :-)

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump