I have 2 applications; one is the main program, the other is a mini updater program.
The idea is, by clicking a button on the main program you close it and call the updater.
However the updater crashes everytime saying it can't do anything with the main program because it is being used by another process. If I call the updater by itself it works just fine.
Is there any way to properly close the main application before updating?
Here's the code that calls the updater:
If UpdateAvailable() = True Then
Process.Start(frm_Main.AppData & "\Updater.exe")
Application.Exit()
End If
Updater code:
Dim myProcesses() As Process
Dim myProcess As Process
myProcesses = Process.GetProcessesByName("U-Certify Electrics Certificate Manager.exe")
For Each myProcess In myProcesses
MsgBox(myProcess.ProcessName)
myProcess.Kill()
Next
myProcess = Nothing
myProcesses = Nothing
Try
My.Computer.FileSystem.RenameDirectory(ToReplace, BeReplaced)
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
The program crashes when renaming the file that the main application is in.