Sub GetFullName() Dim objWMIService, colProcessList As Object Dim uname, udomain As String Dim objProcess As Object Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'EXCEL.EXE'") For Each objProcess In colProcessList objProcess.GetOwner uname, udomain Next MsgBox UCase(udomain) & "\" & UCase(uname) End Sub
這裡介紹一個WMI程式碼產生器,是由微軟所提供,有需要可至網站下載 WMI Code Creator v1.0
沒有留言:
張貼留言