none
How to get the installation folder

    Question

  • 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:

    [CODE]
        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")
                Else
                    Microsoft.VisualBasic.Shell(path & "activate.exe")
                End If
        End Sub
    [/CODE]

    The problem is how to get the installation dir?

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

Answers

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"

    http://forums.msdn.microsoft.com/en-US/netfxsetup/thread/561d2c16-c56c-4d7d-9eda-3719deaa7bea/

    "Getting installation path in SetUp project"
    http://forums.asp.net/t/1292869.aspx


    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