From: daz Date: 2009-03-10T12:28:11+09:00 Subject: Re: Finding Process Name using Window Handle >>> Oops, that was to the wrong thread. Anukul Singhal wrote: > Hi, > > In my project, I have a requirement to work with any client application > which I need to kill (if an instance exists) before invoking a fresh > instance. Currently, I have hardcoded the name of the process to > terminate a client before opening it. What I am looking for is a way to > find the process name (using any Win32API or using a Window Handle). I > found out how to get a Window Handle for the client application that is > invoked, is that something I can use to get the process name, or any > other way? Please see the code I am using: > > def killApp > wmi = WIN32OLE.connect("winmgmts://") > processes = wmi.ExecQuery("select * from win32_process") > for process in processes do > if process.Name.include? "AppName.exe" then > process.Terminate > end > end > end > > Would really appreciate your help. > > Thanks, > Anukul Hi, I only looked briefly at this but you might find some clues from solutions in other languages and be able to convert them yourself. http://forums.networkautomation.com/forum/messageview.cfm?FTVAR_FORUMVIEWTMP=Threaded&catid=4&threadid=2515 http://www.purebasic.fr/english/viewtopic.php?p=264755&highlight=&sid=d3f90592c990c78a0c1039efe8e1167e I hope this is more helpful than getting no reply :) daz