如何在远程计算机上记录用户的空闲时间 [英] how to log the idle time of user on a remote computer

查看:63
本文介绍了如何在远程计算机上记录用户的空闲时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在Java Swing中构建一个应用程序,在该应用程序中服务器应了解客户端是否在其计算机上工作,从某种意义上讲,这是客户端的空闲时间.
有没有一种方法可以使用java找出远程计算机的系统空闲时间.如果远程用户空闲了10分钟,该程序应从我的PC上运行并显示一个消息框.

我希望你能得到我.



谢谢.


i want to build an application in java swing in which the server should come to know whether the client is working on his computer or not which is in the sense it is the idle time of the client.
Is there a way to find out the system idle time of a remote computer using java.The program should run from my pc and should show a message box if the remote user is idle for 10 minutes.

I hope you get me.



thank you.

推荐答案

如果您的远程计算机是Windows,则可以使用远程wmi来执行此操作.只是谷歌的WMI CPU使用率和远程WMI. WMI是COM-因此您必须建立从Java到COM的某种形式的桥梁.如果远程计算机不是Windows,则可以使用像旧版TOP这样的工具,但是您将必须弄清楚如何以所需的方式恢复数据.

我怀疑最简单(也许不是最好的)是创建一个VBScript以使用WMI监视远程计算机并将结果写入stdout.然后使用Java之类的"cscript script.vbs"启动该脚本,如下所示:

If your remote machine is windows, then you can use remote wmi to do this. Just google WMI CPU Usage and Remote WMI. WMI is COM - so you''ll have to then build some form of bridge from Java to COM. If the remote machine is not Windows - then there are tools out there like good old TOP - but you''ll have to then figure out how to get that data back in the way you want.

I suspect the very easiest (maybe not the nicest) is to create a VBScript to monitor the remote machine using WMI and write the result to stdout. Then launch that script via "cscript script.vbs" using the Java something like this:

Process p = Runtime.getRuntime().exec("script scripts.vbs");


困难的方法
http://ochafik.free.fr/blog/?p=98 [
The hard way
http://ochafik.free.fr/blog/?p=98[^]

The easy way
use a timer and tasklist.exe


这仅在远程计算机上有某些进程可以为您捕获信息时才有效.

在Alex的全面回答之后,我快速浏览了Remote WMI,并且我同意可以很好地满足您的需求.但是,要通过Java访问该文件,您需要使用
JNI [ ^ ]接口和您自己的C ++库,或者您可以直接通过 JNA [ ^ ].
This can only work if you have some process on the remote computer that captures the information for you.

Following on from Alex''s comprehensive answer I took a quick look at Remote WMI and I agree that may well offer what you need. However, to access that through Java you would need to use either the JNI[^] interface, with your own C++ library, or you may be able to do it direct with JNA[^].


这篇关于如何在远程计算机上记录用户的空闲时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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