Sub GetIpAdr() 'получить IP адрес компа
Dim oWMIObjEx As Object, sWQL As String
sWQL = "Select * From Win32_NetworkAdapterConfiguration"
With GetObject("winmgmts:root/CIMV2")
For Each oWMIObjEx In .ExecQuery(sWQL)
If Not IsNull(oWMIObjEx.IPAddress) Then
Range("IpAdr")(1, 0).Resize(, 4).Value = _
Array("IP:", oWMIObjEx.IPAddress(0), "Host name:", oWMIObjEx.DNSHostName)
End If
Next
End With
Set oWMIObjEx = Nothing
End Sub
Sub test()'Какие приложения запущены на компьютере? (в т.ч. удаленном?)
Dim sComp$, objProcess As Object, i&
sComp = Range("IpAdr").Value: i = 1 'something like "Николай-ПК" or "10.999.97.308"
Range("A1").CurrentRegion.Offset(1).ClearContents
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sComp & "\root\cimv2")
For Each objProcess In .ExecQuery("Select * from Win32_Process")
i = i + 1
Cells(i, 1) = objProcess.Name
Cells(i, 2) = objProcess.ProcessId
Cells(i, 3) = objProcess.ThreadCount
Cells(i, 4) = objProcess.PageFileUsage
Cells(i, 5) = objProcess.PageFaults
Cells(i, 6) = objProcess.WorkingSetSize
Next
End With
Set objProcess = Nothing
End Sub
|