系统相关
首页 > 系统相关> > 如何用java连接远程windows机器?

如何用java连接远程windows机器?

作者:互联网

我想从使用Java程序的本地计算机连接到远程Windows桌面.
我必须检查远程计算机中的磁盘空间和其他几项服务.

解决方法:

远程桌面连接

JAVA

// creating credentials
Process p = Runtime.getRuntime().exec("cmdkey /generic:"+ip+" /user:"+userName+" /pass:"+password );
p.destroy();

Runtime.getRuntime().exec("mstsc /v: "+ip+" /f /console");

Thread.sleep(2*60*1000); // min sec millisec
// deleting credentials
Process p1 = Runtime.getRuntime().exec("cmdkey /delete:"+ip);
p1.destroy();

>通过使用cmdkey,我们可以创建或删除特定于当前用户的凭据.

Command line

C:>cmdkey /generic:192.168.0.11 /user:XXXXX /pass:XXXXX
     CMDKEY: Credential added successfully.
C:>mstsc.exe /v:192.168.0.11 /w:800 /h:600
     Connecting to Remote Desktop.
C:>cmdkey /delete:192.168.0.11
     CMDKEY: Credential deleted successfully.

标签:java,remote-access
来源: https://codeday.me/bug/20190610/1211050.html