When a User closes the application it triggers the following VBA code that will Terminate the Everything.exe process for that specific User.
Code: Select all
Public Function CloseEverything()
Dim oServ As Object
Dim cProc As Variant
Dim oProc As Object
Dim strOwner As String
Set oServ = GetObject("winmgmts:")
Set cProc = oServ.ExecQuery("Select * from Win32_Process Where Name = 'Everything.exe'")
For Each oProc In cProc
If Nz(oProc.ExecutablePath) <> "" Then
oProc.GetOwner strOwner
If strOwner = Environ("USERNAME") Then
oProc.Terminate
Exit For
End If
End If
Next
End Function
Is there some way that I can modify the VBA code so that it will update the database prior to terminating the process? Alternatively, maybe there is a way to Quit the Everything process with VBA, rather than Terminate the process and lose the database changes.