Quit vs Terminate the Everything process

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
DanoLeMano
Posts: 8
Joined: Sat Jul 17, 2021 10:30 pm

Quit vs Terminate the Everything process

Post by DanoLeMano »

I am using Everything in my MS Access application that is shared by multiple users (3) on the same computer. Each USERNAME connects to their own Windows Profile, and uses the same shared database file specified in Everything Options to be in this location: C:\Program Files (x86)\Everything\Everything.db

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
The problem is that when the Everything process is terminated, the database is not updated. The database is only written to disk when the user manually closes Everything using File->Quit.

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.
DanoLeMano
Posts: 8
Joined: Sat Jul 17, 2021 10:30 pm

Re: Quit vs Terminate the Everything process

Post by DanoLeMano »

Silly me. This was very easy once I read the documentation. :)

Here is the revised code the makes use of the -quit Command Line Option:

Code: Select all

    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
                Dim c As String 
                Dim w As Object
                c = "Everything.exe [b]-quit[/b]"
                Set w = CreateObject("WScript.Shell")
                w.CurrentDirectory = "C:\Program Files (x86)\Everything\"
                w.Run c, 0, True                                       
                Exit For
            End If
        End If
    Next
Post Reply