How to get the installation folder


  • Hi!

    I created a service, a windows form and a setup project in VB.NET.

    And after install I need the installation directory to something like this:

        Private Sub ServiceProcessInstaller1_AfterInstall(ByVal sender As System.Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles ServiceProcessInstaller1.AfterInstall
                Dim path As String = Me.TARGETDIR 'not working
                If System.IO.File.Exists(path & "res.dll") Then
                    Microsoft.VisualBasic.Shell("net start update_service")
                    Microsoft.VisualBasic.Shell(path & "activate.exe")
                End If
        End Sub

    The problem is how to get the installation dir?

    Can anyone help me?
    Thursday, August 21, 2008 1:34 PM


All replies

  • Something like this...
    Imports System  
    Public Class MainClass  
       Shared Sub Main()  
            Console.WriteLine("CurrentDirectory:   " & System.Environment.CurrentDirectory )  
       End Sub   
    End Class 
    Thursday, August 21, 2008 1:58 PM
  • No, this is a Setup project.
    I need the [TARGETDIR] after installation.
    But thx
    Thursday, August 21, 2008 2:12 PM
  • Please, anyone?
    i'm stuck at this
    Saturday, August 23, 2008 8:28 PM
  • dream.falcon said:

    No, this is a Setup project.
    I need the [TARGETDIR] after installation.

    Hi dream,

    There is a built-in argument with a key value of assemblypath that's the full assembly path.

    Dim strAssemplyPath As String = Context.Parameters("assemblypath").ToString()
    Dim strAppPath As String = strAssemplyPath.Substring(0, strAssemplyPath.LastIndexOf("\"))

    The variable strAppPath value will be the installation folder.

    Please check these threads having the similar issues.

    "How to get the Install path of the deployed application"

    "Getting installation path in SetUp project"

    Additionally, the ClickOnce and Setup & Deployment Projects forum is more appropriate for such issues.

    Best regards,
    Martin Xie

    Wednesday, August 27, 2008 11:38 AM