With this code I could easily grab any system process from any computer I state, but I'm stuck with case when I need username/password! Btw, I would know username and password, just don't know how to pass it!
Public Function pChecker(sExeName As String, Optional sComputer As String = ".") As Boolean On Error GoTo Error_Handler Dim objProcesses As Object Set objProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2").ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & sExeName & "'") If objProcesses.Count <> 0 Then pChecker = True Error_Handler_Exit: On Error Resume Next Set objProcesses = Nothing Exit Function Error_Handler: MsgBox "The following error has occured." & vbCrLf & vbCrLf & _ "Error Number: pChecker" & vbCrLf & _ "Error Description: " & Err.Description, _ vbCritical, "An Error has Occured!" Resume Error_Handler_Exit End Function Function oChecker(strHost As String) As Boolean Dim strQuery As String strQuery = "select * from Win32_PingStatus where Address = '" & strHost & "'" Dim colItems As Object Set colItems = GetObject("winmgmts://./root/cimv2").ExecQuery(strQuery) Dim objItem As Object For Each objItem In colItems If IsObject(objItem) Then If objItem.StatusCode = 0 Then oChecker = True Exit Function End If End If Next End Function
Bookmarks