Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I have list of computers name and I need to find out if any user logged on to those computers. Is it possible using Java or Java Script without writing code on remote machine?

Currently I have code that pings to computer and tells whether its reachable or not but I need to find out if anyone logged in to those machines and who is logged in.

Java
private String getStatus(String machineName) {
        String result = null;
        try {
            InetAddress inet = InetAddress.getByName(machineName);
            System.out.println("Sending Ping Request to " + machineName);

            boolean status = inet.isReachable(5000); //Timeout = 5000 milli seconds

            if (status) {
                result = "Reachable";
            } else {
                result = "Unreachable";
            }
        } catch (UnknownHostException e) {
             result = "Host does not exists";
        } catch (IOException e) {
             result = "Error in reaching the Host";
        }
        return result;
    }
Posted
Comments
Sergey Alexandrovich Kryukov 3-Mar-15 1:20am    
Not clear. Aren't you mixing up layers and tiers?
—SA
Richard MacCutchan 3-Mar-15 3:50am    
Unless the remote computer provides this information you cannot get it.

1 solution

You can do so, but you require a tool/utilities which can connect to remote computer for example PStools utility, You may find similar on google. Once you get the tool, you can use java Runtime.getRuntime() to execute command prompt commands.

To know more about PStool here is the link http://www.howtogeek.com/school/sysinternals-pro/lesson8/all/[^]

Hope this info helps you.

Regards,
Panduranga.
 
Share this answer
 
Comments
Gajanan Hole 3-Mar-15 9:20am    
Thank you very much!! But I am trying to achieve this without using external tool.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900