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.
Use Remote Desktop to connect to the PC you set up: On your local Windows PC: In the search box on the taskbar, type Remote Desktop Connection, and then select Remote Desktop Connection. In Remote Desktop Connection, type the name of the PC you want to connect to (from Step 1), and then select Connect.
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();
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With