Installer Custom Action in msi setup

Hi guys,

I am developing a windows installer for my windows application. What I do is during the installation ,at the end, the setup asks for login credentials. I have overriden the commit method of installer class thus causing custom action to fire.

Here is my code :

    <Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)> _

Public Overrides Sub Commit(ByVal savedState As  _

  System.Collections.IDictionary)

 

        MyBase.Commit(savedState)

 

 

        If Not File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DBConnect.xml") Then

            Dim frm As New Login

            frm.TopMost = True

            frm.ShowDialog()

            frm.BringToFront()

            frm.Activate()

            frm.Focus()

            frm.WindowState = Windows.Forms.FormWindowState.Maximized

 

This works perfectly . But now I want to fire this custom action afetr installation has been completed so I have modified the code as:

 

  Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

        MyBase.OnAfterInstall(savedState)

        ' Add steps to be done after the installation is over.

        If Not File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DBConnect.xml") Then

            Dim frm As New Login

            frm.TopMost = True

            frm.ShowDialog()

            frm.BringToFront()

            frm.Activate()

            frm.Focus()

            frm.WindowState = Windows.Forms.FormWindowState.Maximized

 

 

        End If

 

    End Sub 'OnAfterInstall

 

        End If


So  as you can see I have used OnAfterInstall methos to override .But my problem is
The custom action still fires before the installation & not after installation is completed.

Any help  ill be appreciated

vikasbapatAsked:
Who is Participating?
 
Vadim RappCommented:
Not a definitive answer, but I would be surprised if Installer allowed doing anything after the commit. Most likely it simply can't commit with your custom action in progress, so it postpones the commit until custom action has finished. It's like baron Minhauzen who tried to get out of the lake by pulling his own hair up.

Usually, when something needs to be done before or after the installation, it goes into the setup.exe. But I'm sure you realize that the whole idea is breaking the concept of the installation being able to rollback -if for whatever reason your after-commit code fails, the system will be left in intermetiate state.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.