Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Small problem with Custom action and Uninstalling


12 replies to this topic

GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 16 September 2008 - 17:25

Hi Guys, heres the problem. I have a Custom Action integrated into my IS project. Its a VBScript that detects whether or not the application Im trying to uninstall is still open. If it is, display a messagebox listing the offending process(es)
and return an error code of 1602. This is enough to stop the uninstallation. So far, so good!

My test is to open the application which I have just installed. Then open "Add/Remove Programs" and attempt to remove the program. I get the expected messagebox but before the uninstall is cancelled, I see a second message box "Fatal error during installation".

Does anyone know why I see that? More Importantly, any way to supress it?

Thanks guys!

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 17 September 2008 - 16:07

I think that a result of your returning 1602 and I don't think you can avoid it.

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 18 September 2008 - 09:08

Change your Custom Action:
- It should set some private property
- It should return 0

Add another Custom Action immediatly after your Custom Action. The condition is the same private property from your Custom Action, the . Read the docs on type 19.

GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 08 October 2008 - 14:10

Thanks for the replies guys.

Zweitze - what do you mean about type 19? What does the second custom action do exactly?

Thanks again.

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 08 October 2008 - 18:54

See http://msdn.microsof...y/aa368078.aspx

Quote:
"Custom Action Type 19
This custom action displays a specified error message, returns failure, and then terminates the installation. The error message displayed can be supplied as a string or as an index into the Error table."


GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 13 October 2008 - 14:25

Hi again guys, still suffering with this one Im afraid! Again, my custom action will display the messagebox but now its not aborting the install.

Ive inserted a record into the Custom Actions table :
Action - CancelInstallation
Type - 19
Target - "Installation will abort"

Is this correct? Does the Action name(CancelInstallation) need to be the same as my Custom Action? Ive tried returning 19 from my CA but no good.

Zweitze - you proposed a second action - what does it check for and where?
Im using vbscript if its any help.


GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 13 October 2008 - 17:08

Ok, quick update. I created a property in the Property table "CancelInstall" which is set to false. I also have an entry in the CustomAction table called "ConfirmUninstall" with a type 19.

If the conditions to cancel the Install are true in my Custom Action I use this : Session.Property("CancelInstall") = True.

So the last stage of my quest : how does my second Custom Action reference the Type 19 "ConfirmUninstall" to quit the install?


vijayakumar

vijayakumar
  • Full Members
  • 43 posts

Posted 14 October 2008 - 05:57

Answering your first thread in this post, how are you writing your vbscript custom action. What is the return value of this CA?
Are you returning the error code 1602 manually??

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 14 October 2008 - 09:38

QUOTE
So the last stage of my quest : how does my second Custom Action reference the Type 19 "ConfirmUninstall" to quit the install?


You shouldn't call that CA from your CA. Instead put the type 19 CA immediatly after the CA that sets the property CancelInstall.

So, if your CA is called by a sequence, put the CA immediatly after your CA.
If your CA is called by an event (in a dialog, eg. when a button is pressed), put the CA after that.

Edited by Zweitze, 14 October 2008 - 09:39.


GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 14 October 2008 - 15:07

QUOTE (vijayakumar @ 2008-10-14 05:57)
Answering your first thread in this post, how are you writing your vbscript custom action. What is the return value of this CA?
Are you returning the error code 1602 manually??



I was returning 1602 manually. The Return processing in the Msi is set to Synchronous(Check exit code). the uninstall would stop as expected but I still got that second message box popping up reporting a Fatal Error. The VBScript looks like :

function ConfirmUninstall()

Dim objWMIService, objProcess, colProcess
Dim strComputer, strList, strProspectProcess
dim strMessage, retval


strProspectProcess = My Process List of Exe's
strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")

For Each objProcess in colProcess
If Instr(1,strProspectProcess, objProcess.caption) > 0 then
strList = strList & vbCrLf & objProcess.Name
end if
Next

strMessage = "The following Processes are running and must be shutdown " _
& "before Installation can continue. " _
& vbCrLf & strList & vbCrLf & vbCrLf _
& "Setup will abort."


if Len(strList) = 0 then
ConfirmUninstall = 0
else
msgbox strMessage, vbCritical, "Cannot Continue"
' exit the installation
ConfirmUninstall = 1602
end if

end function


QUOTE (Zweitze)
You shouldn't call that CA from your CA. Instead put the type 19 CA immediatley after the CA that sets the property CancelInstall.

So, if your CA is called by a sequence, put the CA immediatly after your CA.
If your CA is called by an event (in a dialog, eg. when a button is pressed), put the CA after that.

Ok, Almost there. the last thing I need to know is how to make it happen. My second CA is called after my first. It will check the property "CancelInstall" and if set to True, I want Type 19 to do its thing. What do I do exactly? ( I have an entry in the CustomAction table called "ConfirmUninstall" with a type 19.)

vijayakumar

vijayakumar
  • Full Members
  • 43 posts

Posted 14 October 2008 - 15:31

Hi,

Change the return value in your script function to 2
(change this line ConfirmUninstall = 1602 to ConfirmUninstall = 2)..

This will do the trick (Suppress the second 'Fatal' error message).

-Vijay

GalwayDude

GalwayDude
  • Full Members
  • 10 posts

Posted 14 October 2008 - 17:10

Wow, that did it! Good stuff Vijay! biggrin.gif

Thanks to Zweitze and Stefan too for your help.

Cheers All !

rameshkannamalla

rameshkannamalla
  • Full Members
  • 5 posts

Posted 21 February 2012 - 12:50

Hi ,

I also added similar type of code.
Even though I return 2 from my function It is prompting the error.
I am using InstallScript function.

I set the following under CA:
1. Return processing = Synchronous(Check exit code).
2. In Script Execution = Immediate Execution
3. ExecuteScheduling = Always Execute
4. Install UI Sequence = After Maintenance Welcome
5. Install Exec Sequence = After Remove files.

Add remaining all default settings.

So Can you help me how to get rid of that Fatal Error?

Thanks in advance,

Ramesh.