none
help with custom action Commit to execute application

    Question

  • Hello all I have been fighting for literally hours trying to figure out how to create a custom action in my installation project that will do the simplest thing; launch the application. I have figured out that I need to create a dll with a commit sub that will launch the program.

    I receive an error "Object reference not set to instance of an object".

    how can I make this code below execute my applicaiton in it's install path?

      Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)

            MyBase.Commit(savedState)

          
            MsgBox(savedState("TargetDir").ToString()) 'BLOWS UP HERE

            System.Diagnostics.Process.Start(savedState("TargetDir").ToString() & "MyApplicationName")
        End Sub
    Saturday, January 19, 2008 12:07 AM

Answers

  • I have resolved this issue. Judging by the number of views without responses this seems to be a big issue (meaning people don't understand how to do this). Below are the steps to take to make your application launch after installation.

    1. Create a new project using the Class Library template.
    2.
    Add a new Installer Class to the project. Delete the default file Class1.cs (or Class1.vb).
    3. In the code for the installer class add this code.


    Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
            MyBase.Commit(savedState)
            System.Diagnostics.Process.Start(Context.Parameters("TARGETDIR").ToString() & "myapplication.exe")
        End Sub
    4. Go back to your setup projec thtat you have created and go to the custom actions properties.
    5. Right click on the Commit action folder and add a new action.
    6. select the output from this installer class output from the class library.
    7. Now you will see the action created and under the commit file folder. Click on the 'primary output from depend (active)' item under the folder.
    8. Under the properties for this add the this /TARGETDIR="[TARGETDIR]\" Into the spot for customactiondata.
    Make sure that you include the slashed and bouble quotes in the spots I have above.

    9. Now build the setup project. Then click install (everything is under the projects file menu.


    enjoy. It took me a long time to figure this out. I hope it saves some of you time.....



    Monday, January 21, 2008 4:31 PM

All replies

  • I have resolved this issue. Judging by the number of views without responses this seems to be a big issue (meaning people don't understand how to do this). Below are the steps to take to make your application launch after installation.

    1. Create a new project using the Class Library template.
    2.
    Add a new Installer Class to the project. Delete the default file Class1.cs (or Class1.vb).
    3. In the code for the installer class add this code.


    Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
            MyBase.Commit(savedState)
            System.Diagnostics.Process.Start(Context.Parameters("TARGETDIR").ToString() & "myapplication.exe")
        End Sub
    4. Go back to your setup projec thtat you have created and go to the custom actions properties.
    5. Right click on the Commit action folder and add a new action.
    6. select the output from this installer class output from the class library.
    7. Now you will see the action created and under the commit file folder. Click on the 'primary output from depend (active)' item under the folder.
    8. Under the properties for this add the this /TARGETDIR="[TARGETDIR]\" Into the spot for customactiondata.
    Make sure that you include the slashed and bouble quotes in the spots I have above.

    9. Now build the setup project. Then click install (everything is under the projects file menu.


    enjoy. It took me a long time to figure this out. I hope it saves some of you time.....



    Monday, January 21, 2008 4:31 PM
  • Thanks a lot for this code. Works perfect.

     

    One question:

     

    My application displays the username of the currently logged in user. After being installed, my application shows the "SYSTEM" user as currently logged on user, which isn´t correct. Is there a way to start the application in another process (logged in user) without knowing username and password (Process.Start offers a method to do so)?

     

    Thanks in advance...

     

    Friday, February 22, 2008 1:33 PM
  • Humm.. honestly I don't know. I would imagine there is a solution to this. there might be a way to check the registry for the user? (I am just shooting blanks)


    Tuesday, February 26, 2008 10:39 PM