How to get the installation directory in a Custom Action?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BudgetGuru
    New Member
    • Dec 2010
    • 2

    How to get the installation directory in a Custom Action?

    I am using Visual Studio 2005. I have just figured out how to create a Custom Action during installation, but I can not figure out how to get data from the installer. Following is the simple test code that I am trying to use to call the directory that the user defines during installation, but the Path string is not returning anything.

    Public Overrides Sub Install(ByVal stateSaver As System.Collecti ons.IDictionary )
    MyBase.Install( stateSaver)
    Dim Path As String = MyBase.Context. Parameters("tar getdir")
    Dim AppConfigFile As String = Path & "\Files\AppConf ig.txt"
    MsgBox("The target filepath is: " & AppConfigFile)
    End Sub

    I have tried many other things, such as...
    Me.Context.para meters("targetd ir")
    stateSaver.item ("targetdir" )
    etc.
    And I entered /INSTALLDIR="[TARGETDIR]\" in the custom action data property.
    Nothing is working.

    Thanks.
  • BudgetGuru
    New Member
    • Dec 2010
    • 2

    #2
    I figured out what the issue was. My custom action data property was not correct. It should have been
    /targetdir="[TARGETDIR]\"
    to match the parameter value in the code itself.

    I also learned that other parameters can be captured in a similar way in the custom action data property, such as...
    /parameter1="[EDIT1A]"
    from a user entry text box.

    Comment

    Working...