Anyone know how to get a third party application's installation directory?

Recommended Answers

All 2 Replies

You actually can do it in different ways...
1. using the WMI class

Private Sub GetInstalledProducsByWindowsInstaller() 'need Imports System.Management and its needed reference
        Try
            Dim moc As ManagementObjectCollection
            Dim mos As ManagementObjectSearcher
            Dim mo As ManagementObject

            mos = New ManagementObjectSearcher("Select * from Win32_Product WHERE Name = 'ThirdPartyApp'")
            moc = mos.Get
            For Each mo In moc
                Dim Result As String = String.Format(" {0} {1} {2} {3} {4} ", _
                mo("Name"), " = ", _
                DateTime.ParseExact(mo("InstallDate").ToString(), "yyyyMMdd", Nothing).ToShortDateString(), _
                " = ", mo("InstallLocation"))
                Debug.writeline(Result)
            Next
        Catch ex As Exception
            Debug.writeline(ex.Message)
        End Try
    End Sub

2. using the process class (if the process is running)

Sub GetProcessInfo()
		Dim proc() As Process = Process.GetProcessesByName("explorer")	  'thirdPartyApp
		If proc.Count <> 0 Then
			Debug.WriteLine(IO.Path.GetDirectoryName(proc(0).MainModule.FileName))
		End If
	End Sub

3. reading the desired registry locations such as:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall

commented: Perfect answer +2

Awesome information!!! I couldn't find anything this afternoon on this. Thank you so much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.