Below is the function that is used to kill any process:
Public Function fnProcessKill (ByVal strProcess)
Dim FunctionName: FunctionName = UCase ("fnProcessKill")
Dim strPreFix: strPreFix = "In " & pcThisLib & " - " & FunctionName & ","
Set objSWbemServices = GetObject("winmgmts:")
Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Process Where Name = '"& strProcess &"'")
If colSWbemObjectSet.Count > 0 Then
For i = 1 to colSWbemObjectSet.Count
SystemUtil.CloseProcessByName(strProcess)
Next
Else
fnProcessKill = micFail ' Did not find the process.
End If
Set objSWbemServices = Nothing ' Clear object from memory.
Set colSWbemObjectSet = Nothing ' Clear object from memory.
End Function
Public Function fnProcessKill (ByVal strProcess)
Dim FunctionName: FunctionName = UCase ("fnProcessKill")
Dim strPreFix: strPreFix = "In " & pcThisLib & " - " & FunctionName & ","
Set objSWbemServices = GetObject("winmgmts:")
Set colSWbemObjectSet = objSWbemServices.ExecQuery("SELECT * FROM Win32_Process Where Name = '"& strProcess &"'")
If colSWbemObjectSet.Count > 0 Then
For i = 1 to colSWbemObjectSet.Count
SystemUtil.CloseProcessByName(strProcess)
Next
Else
fnProcessKill = micFail ' Did not find the process.
End If
Set objSWbemServices = Nothing ' Clear object from memory.
Set colSWbemObjectSet = Nothing ' Clear object from memory.
End Function
No comments:
Post a Comment