Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How to set or get InstallLocation for Setup and deployement Project because while i write below snippet its returns empty

VB
Dim registry_key As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Using key As Microsoft.Win32.RegistryKey = Registry.LocalMachine.OpenSubKey(registry_key)
        For Each subkey_name As String In key.GetSubKeyNames()
            Using subkey As RegistryKey = key.OpenSubKey(subkey_name)
                If subkey.GetValue("DisplayName") = "Application Name" Then
                    Return subkey.GetValue("InstallLocation")
                End If
            End Using
        Next



SQL
subkey.GetValue("InstallLocation")

Will work fine for some Application and for some its not .
but i need to read location by providing application name of MSI please help me (whew)
Posted
Updated 3-Feb-14 2:44am
v2

You may use the executing assembly location like this:
VB
Public Shared Function GetAssemblyDirectory() As String

        Return (Path.GetDirectoryName(New Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath))

End Function


In addition, as I understand, you use custom actions in the setup project.

You may pass installer property values to custom actions in CustomActionData field.

For example:
/AllUsers=[ALLUSERS] /ProductName=[ProductName] /ProductLanguage=[ProductLanguage]

In the custom action you may use the values using the Context object like this:
VB
Dim productName As String = Context.Parameters("ProductName")
Dim productLanguage As String = Context.Parameters("ProductLanguage")


See a complete list of standard installer properties at
http://msdn.microsoft.com/en-us/library/aa370905(v=vs.85).aspx[^]
 
Share this answer
 
v2
Comments
Vishwanath.284 3-Feb-14 5:33am    
subkey.GetValue("InstallLocation")
Will work fine for some Application and for some its not .
but i need to read location by providing application name of MSI please help me (whew)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900