Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process for a specific user

Status
Not open for further replies.

TheWizard78

Programmer
Jun 28, 2004
18
CA
Hi,

I just found on this forum some code for listing all the process running on my computer. The problem is that my computer is a windows server and it also list the process of other user. I would like to see only mine. Is there a way to do it? I'm searching using the exe filename, not the title, but is that possible to retreive it with this function?

here is the code use to verify is the process is running.

LPARAMETERS lcProcess
lcComputer = "."
loWMIService = Getobject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ("Select * from Win32_Process")
FOR EACH loProcess IN colProcessList
IF UPPER(loProcess.name)==UPPER(lcProcess)
RETURN .T.
ENDIF
ENDFOR
RETURN .F.

Also, where can I find some help or other great function like this one using the «Getobject("winmgmts:"...», because they are very usefull?

thanks

Robert
 
Hi,

Thanks Mike Gagnon for the response.
Here is the code I just found on your link.
I have convert this example into foxpro code, but the variable aa doesn't return me the username, she still empty.
Do you know why?

lcComputer = "."
loWMIService = Getobject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ("Select * from Win32_Process")
FOR EACH loProcess IN colProcessList
aa=""
IF loProcess.getowner(aa)==0
? UPPER(loProcess.name)+" run by "+aa
endif
ENDFOR

thanks

Robert
 
Robert

Although WMI Object Browser does retreive the owner of the process, it does not seem to work in VFP (At least not this way). Most likely you need a couple of API calls to retreive the info your are after.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Hi,

Thanks again Mark for your answer.

I'm not really an expert with API.
I just look over news2news website, but I really don't know which function I need to look for and how I will use it. Even if I have look in Process and Thread

But I have also another API source code that I have work with. And it only return me process of my session, because it only look for opened window on my desktop (FindWindowEx).

But my problem with this one, it's that I don't have the filename of the program running according to the process id.

Could someone help me with that one please

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top