[python-win32] Question: Finding the "owner" Of A Process

Gooch, John John.Gooch at echostar.com
Thu Jun 2 17:10:12 CEST 2005


I am trying to print out the owner of running process on Windows 2000
Professional ( SP4 ) using WMI, but my call to the "GetOwner" Process
defined here -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
getowner_method_in_class_win32_process.asp
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi
/getowner_method_in_class_win32_process.asp> , which is part of the
Win32_Process Class defined here -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
wmi_tasks__processes.asp
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi
/wmi_tasks__processes.asp>  .



Here is my code, followed by the error message:


import odbc
import socket
import re
import win32com.client
import win32api
import win32con
import win32file
import pythoncom
import datetime
import os

pythoncom.CoInitialize()
#connect to localhost wmi service
wmi = win32com.client.GetObject('winmgmts://' )
procs = wmi.ExecQuery( "SELECT * FROM WIN32_PROCESS")
user = ""
domain = ""
for proc in procs:
        proc.GetOwner( user, domain )
        print "%s's owner is %s" % ( proc.Name, user   )
x.GetOwner()


Error:
Traceback (most recent call last):
  File "C:\Documents and Settings\John.Gooch\My Documents\File
Manager\getowner.py", line 20, in ?
    proc.GetOwner( user, domain )
TypeError: 'int' object is not callable



Any ideas? I tried using the proc.Method('GetOwner') syntax to locate the
function, but I don't know how to pass in paramaters ( explained on
Microsoft's site ) to the function using that syntax.

Thank You, 


John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO  80112
Desk: 720-514-5708 





John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO  80112
Desk: 720-514-5708 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050602/03417617/attachment.html


More information about the Python-win32 mailing list