Click here to Skip to main content
14,365,424 members
Rate this:
Please Sign up or sign in to 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.

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
   
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100