• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Getting application Name from TaskManager

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai All,

I need a great help from all java friend.I need to get the all currently running application in a system from the task manager.Is it possible to do it from java.Can anyone say the way to do it.Is there any API for it.

Thanks.
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There isn't any API for this in Java itself (or at least not one from Sun), but with JNI you can build one yourself.

However, there is a much easier way: use a ProcessBuilder to execute the tasklist.exe command (try tasklist /? on a command prompt to see the options). Please search for and read the article "When Runtime.exec() won't" if you use this approach.
 
Marshal
Posts: 76884
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
preethi balaJain
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, ritchie.
 
preethi balaJain
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply.My requirement is,I want to trace a .exe like,how long it is running.So i prefered the way of getting details from taskmanager.Now,it seems like its not going to be any easy way.Is there any other way to do it?
 
Campbell Ritchie
Marshal
Posts: 76884
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to start the .exe with Runtime.exec()? You can try getting the time from methods of the System class before and after executing it.

Beware: if you are not familiar with Runtime.exec() read the article by Michael Daconta, which you can find from when Runtime.exec() won't.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have another solution using VBScript. No java code..

I am using WMIs ExecNotificationQuery.

You can provide following query as input to this function

select * from __InstanceDeletionEvent where TargetInstance isa 'Win32_Process'


Let me know, if this helps you.
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic