Windows NT and Java.......

Hi,

I know that this topic doesn't belong to this forum but I couldn't find any other good answers.

I am working on a Windows NT WorkStation. I want to develop a program in Java which will find.....

How many uses are logged on and what is the IP addresses ( TCP/IP ) of the systems who are logged on. Is it possible in Java to find the users in Windows NT.? Please help me. Ay examples or codes will be highly helpful.

Thanks

Deepak

[479 byte] By [Deepak_sh] at [2007-9-26 1:48:31]
# 1

One way is to make system calls using the Runtime.exec() method. Though it may be difficult to get (parse?) the information from the command's output...

String[] commandLine = new String[]{ "command", "param1", "param2" };

try

{

Process p = Runtime.getRuntime().exec(commandLine);

}

catch(IOException e)

{

e.printStackTrace();

}

p_b at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...
# 2
Hi,Is there any other way by which I can know the users that have logged on and their IP address. As you said it seems difficult to get the IP Addresses..ThanksDeepak
Deepak_sh at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...
# 3
using the exec method (as p_b stated) make a 'net session' call, that will list any connected users and their machines. Read the input stream from the returned process and parse.Then use java.io.net.InetAddress to get the IP addess of the machine.
PickardT at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...
# 4
Hi Tim,Can you please help me with some codes or examples.. I tried to do that but I couldn't succed.ThanksDeepak
Deepak_sh at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...
# 5

Get the Inputstream from the Process object and apply a BufferedReader on it...

String[] nativeCmd = { "ntCommand", "param1", "param2" };

Process proc = Runtime.getRuntime().exec(nativeCmd);

BufferedReader bufr = new BufferedReader ( new InputStreamReader( proc.getInputStream () ) );

String s = null;

while ( (s = bufr.readLine ()) != null)

{

System.out.println(s);

}

Hope it works...

p_b at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...
# 6
Hi,Thanks for the helping hand.... and here you win the dukes....Deepak.
Deepak_sh at 2007-6-29 2:48:54 > top of Java-index,Archived Forums,Swing...