Click to See Complete Forum and Search --> : Process


Jessie
October 12th, 1999, 04:04 AM
Hi from Germany!

I need to know the command in Java for showing the processes which are running under WindowsNT (in UNIX it is `ps -e -f`).

Process p = Runtime.getRuntime().exec("????????????????????");

It is really urgent ´cause I need it for my exams! I´d be very glad if somebody could help me soon!

Jessie

unicman
October 12th, 1999, 05:32 AM
Frankly I haven't done Win32 programming. And I don't know if there is any command which shows all the processes on console. If u don't get any command in WinNT to do this, u may consider this alternative.

If u don't find any command in WinNT, there is something called Microsoft API which provides a way to call windows specific calls. There is some call in Win32 API for iterating thro' processes. See if u get a method in Microsoft API. Also to confess, I don't have the API and I am searching for it. Someone had told me that it is available though it costs something.

Or else u may have to write some JNI code for calling the Win32 API call urself.

I don't know how silly or how good this alternative is, but if u don't have any reasonable solution, this may be ur last try.

- UnicMan
http://members.tripod.com/unicman

October 14th, 1999, 02:23 AM
hi jessi
If you want to see the task then you can check out the task manager.

To view list of processes in win-nt , you can use following c / c++ functions
this way you can do it:
EnumProcesses
The EnumProcesses function retrieves the process identifier for each process
object in the system. BOOL EnumProcesses(
DWORD * lpidProcess, // array to receive the process identifiers
DWORD cb, // size of the array
DWORD * cbNeeded // receives the number of bytes returned); Parameters
lpidProcess Pointer to an array that receives the list of process identifiers.
cb Specifies the size, in bytes, of the lpidProcess array. cbNeeded
Receives the number of bytes returned in the lpidProcess array. Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error
information, call GetLastError. Remarks
It is a good idea to give EnumProcesses a large array of DWORD values, because
it is hard to predict how many processes there will be at the time you call
EnumProcesses. To determine how many processes were enumerated by the call to
EnumProcesses, divide the resulting value in the cbNeeded parameter by
sizeof(DWORD).
To obtain process handles for the processes whose identifiers you have just
obtained, call the OpenProcess function. See Also
Process Status Helper Overview, PSAPI Functions, OpenProcess

or
I believe that you can find what you want is psapi.dll. The api isn't
well documented but you may find something about it in the Microsoft
knowledge base.

please use this above solutions ,
i am also trying to solve your problem ,
you can contact me at sachin.deshmukh@usa.net