Hello!

I want to shut down a process (namely AnyDesk.exe).
AnyDesk.exe has 2 processes.

I can terminate one of them using this code below, but for the other, OpenProcess fails with error code 5 (ERROR_ACCESS_DENIED).

What do I have to do to be able to terminate this process, too?

Thank you very much!
Code:
Public Sub KillProcess(ByVal target_process_id As Long)

Dim target_process_handle As Long

    target_process_handle = OpenProcess( _
        SYNCHRONIZE Or PROCESS_TERMINATE, _
        ByVal 0&, target_process_id)
        
    If target_process_handle = 0 Then
        MsgBox "Dll Error " & Err.LastDLLError & " occured while trying to open process."
        Exit Sub
    End If

    If TerminateProcess(target_process_handle, 0&) = 0 Then
        Debug.Assert False
        'MsgBox "Error terminating process"
    Else
       ' MsgBox "Process terminated"
    End If

    CloseHandle target_process_handle

End Sub