1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Private Sub Command1_Click()
Dim svc As Object
Dim sQuery As String
Dim oproc
Dim Msg As String
Dim MsgChemBDs As String
Dim MsgBDs As String
Dim TxtRech As String
On Error GoTo Command1_Click_Error
Set svc = GetObject("winmgmts:root\cimv2")
sQuery = "select * from win32_process"
For Each oproc In svc.execquery(sQuery)
'Debug.Print oproc.Name & " = " & oproc.ExecutablePath
If InStr(1, oproc.Name, "MSACCESS.EXE", vbTextCompare) <> 0 Then
Msg = Trim(oproc.CommandLine)
Msg = Replace(Msg, Chr(34), "")
Msg = Replace(Msg, "]", "")
MsgBDs = Right(Msg, Len(Msg) - InStrRev(Msg, "\"))
TxtRech = "ShellOpenDatabase "
If InStr(1, Msg, TxtRech, vbTextCompare) Then
MsgChemBDs = Right(Msg, (Len(Msg) - (InStrRev(Msg, TxtRech) + Len(TxtRech)) + 1))
Else
TxtRech = "NOSTARTUP "
MsgChemBDs = Right(Msg, (Len(Msg) - (InStrRev(Msg, TxtRech) + Len(TxtRech)) + 1))
End If
Debug.Print "Chemin de la BDs: " & MsgChemBDs
Debug.Print "BDs: " & MsgBDs
End If
Next
Set svc = Nothing
Exit Sub
Command1_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Err.Clear
End Sub |
Partager