如何使用Java或JavaScript让远程计算机登录用户? [英] How can I get remote computer logged in user using Java or JavaScript?

查看:79
本文介绍了如何使用Java或JavaScript让远程计算机登录用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有计算机名称列表,我需要查看是否有用户登录到这些计算机。是否可以使用Java或Java Script而无需在远程计算机上编写代码?



目前我的代码可以ping到计算机并告诉它是否可以访问但是我需要找出是否有人登录这些机器以及谁登录。



 私人 字符串 getStatus(字符串 machineName){
String result = null;
try {
InetAddress inet = InetAddress.getByName(machineName);
System.out.println( 将Ping请求发送到 + machineName);

boolean status = inet.isReachable( 5000 ); // 超时= 5000毫秒

if (status){
result = Reachable;
} else {
result = 无法接通;
}
} catch (UnknownHostException e){
result = 主机不存在;
} catch (IOException e){
result = 到达主机时出错;
}
返回结果;
}

解决方案

你可以这样做,但你需要一个可以连接到远程计算机的工具/工具,例如PStools实用程序,你可能会在谷歌上找到类似的。获得该工具后,可以使用java Runtime.getRuntime()执行命令提示符命令。



在此处了解有关PStool的更多信息是 http://www.howtogeek.com/school/sysinternals-pro/lesson8/all/的链接 [ ^ ] < br $> b $ b

希望这个信息可以帮到你。



问候,

Panduranga。

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

解决方案

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.


这篇关于如何使用Java或JavaScript让远程计算机登录用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆