如何通过Java连接远程Windows计算机? [英] How do I connect a remote Windows machine by Java?

查看:112
本文介绍了如何通过Java连接远程Windows计算机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java程序从本地计算机连接到远程Windows台式机.

I want to connect to a remote Windows desktop machine from a local machine with a Java program.

我必须检查远程计算机上的磁盘空间和其他一些服务.

I have to check the disk space and several other services on the remote machine.

推荐答案

远程桌面连接

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); // Minutes seconds milliseconds
// Deleting credentials
Process p1 = Runtime.getRuntime().exec("cmdkey /delete:" + ip);
p1.destroy();

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