Visual Basic Online Course
How to make sure that an Application is Running and Installed
![]() |
Visual Basic Online Course - Tips |
When you create a Visual Basic 2010 or generally a VB.Net application that relies on another VB.Net application for example an Updater.exe application, you will have to code both sides in order no to enable the user to run Updater.exe without the existence of the Main application, and in order to do so, you will have to make sure that :
- Your Main application is Running.
- Your Main application is Installed.
- Your Main application does exist in the installation folder.
Here are the Codes to do so
1) VB 2010 Get list of all installed applications'Visual Basic Online Course
'VB 2010 Make sure application is installed
Imports Microsoft.Win32
Public Class Form1
Private Sub Form1_Load(sender As System.Object, _
e As System.EventArgs) Handles MyBase.Load
GetInstalledApps(ListBox1)
End Sub
Function GetInstalledApps(ilst As ListBox) As String
Dim DestKey As String = _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
For Each App As String In _
Registry.LocalMachine.OpenSubKey(DestKey).GetSubKeyNames
ilst.Items.Add(App)
Next
Return ilst.Items.ToString
End Function
End Class
2) VB 2010 Get list of all running applications 'Visual Basic Online Course
'VB 2010 Get list of all running applications
Function GetAllRunningApps(ilst As ListBox) As String
'For every process which is running on the computer
For Each p As Process In Process.GetProcesses
'If it doesn't have a title
If p.MainWindowTitle <> String.Empty Then
ilst.Items.Add(p.ProcessName)
End If
Next
Return ilst.Items.ToString
End Function
3) VB 2010 Make sure application exists'Visual Basic Online Course
'VB 2010 Make sure a file exists
Function AppExists() As Boolean
Dim AppPath As String = ("C:\folder\sample\app.exe")
If IO.File.Exists(AppPath) = True Then
Return True
Else
Return False
End If
End Function
By implementing these checks, you ensure that Updater.exe
operates only when the main application is present and active, maintaining the integrity of your update process.
♥ Here are some online Visual Basic lessons and courses: