How to connect a remote computer running Windows through Java?

I want to connect to Windows Remote Desktop from a local computer using a Java program.

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

+4
source share
5 answers

Remote Desktop Connection

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(); 
  • Using cmdkey , we can create or delete our credentials related to the current user.

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. 
+5
source

You can also consider the RDP Java solution.

There are many solutions out there. Check them out on the Java Remote Desktop Project Comparison .

+1
source

The answer depends on what operating system is used on your local computer (host) to connect to the remote target Windows system.

If it is Unix -based, I would recommend using the open source j-Interop library.

Please note that you may need to manually modify the registry in the target window so that it can work correctly (make sure that you are viewing frequently asked questions on the project website). If you find strange problems (exceptions that occur when connecting), here is a good article that helped me solve them: On the left, Windows does not start through DCOM

On the other hand, if you use the Windows host as the host, your life will become much easier. I would recommend using:

Please note that all of the above is an open source project.

The free version, as mentioned above, is j-Integra , but I have never tried using it.

+1
source

You can install the SSH server on your remote desktop and write a Java program using the jcraft and jsch libraries on your local computer to establish an SSH connection to the remote desktop.

+1
source

All Articles