M
Matthias Jarling
Hi,
The following code to end processes works fine, but terminates the processes
of *all* logged on users (if the code is executed by an admin account). I
just want to kill the current users task.
--
Public Function funQuitProcesses(ByVal strProcessName As String) As Boolean
If Len(strProcessName) > 0 Then
Dim objWMI As Object
Set objWMI = GetObject("winmgmts:")
Dim strWMISQL As String
strWMISQL = "SELECT * FROM win32_process WHERE name = '" &
strProcessName & "'"
Dim objProcesses As Object
Set objProcesses = objWMI.ExecQuery(strWMISQL)
Dim objProcess As Object
For Each objProcess In objProcesses
objProcess.Terminate
Next
Set objProcesses = Nothing
Set objWMI = Nothing
funQuitProcesses = True
Else
funQuitProcesses = False
End If
End Function
--
What's the correct where-clause for this? Should be something like 'where
sessionid = " & TheUsersCurrentSessionID ' or 'where "processowner = " &
CurrentUser()'
thanks in advance, MJ
The following code to end processes works fine, but terminates the processes
of *all* logged on users (if the code is executed by an admin account). I
just want to kill the current users task.
--
Public Function funQuitProcesses(ByVal strProcessName As String) As Boolean
If Len(strProcessName) > 0 Then
Dim objWMI As Object
Set objWMI = GetObject("winmgmts:")
Dim strWMISQL As String
strWMISQL = "SELECT * FROM win32_process WHERE name = '" &
strProcessName & "'"
Dim objProcesses As Object
Set objProcesses = objWMI.ExecQuery(strWMISQL)
Dim objProcess As Object
For Each objProcess In objProcesses
objProcess.Terminate
Next
Set objProcesses = Nothing
Set objWMI = Nothing
funQuitProcesses = True
Else
funQuitProcesses = False
End If
End Function
--
What's the correct where-clause for this? Should be something like 'where
sessionid = " & TheUsersCurrentSessionID ' or 'where "processowner = " &
CurrentUser()'
thanks in advance, MJ