0

I am writing a script in python, and part of it needs to connect to a remote computer using rdp. Is there a script or an api that I could use to create this function? Also, if there is not, is there a way to package a rdp application along side python and then use a python script to run it? Any help would be much appreciated. Thanks in advance, Nate

2 Answers2

1

If you need an interactive window, use the subprocess module to start your rdesktop.exe (or whatever).

If you need to run some command automatically, you're probably better off forgetting about RDP and using ssh (with passwordless, passphraseless authentication via RSA or similar), psexec (note that some antivirus programs may dislike psexec, not because it's bad, but because it's infrequently been used by malware for bad purposes) or WinRM (this is what you use in PowerShell; it's like ssh or psexec, except it serializes objects on the sender, transmits, and deserializes back to an object on the recipient).

Given a choice among the 3, I'd choose ssh. Cygwin ssh works fine, but there are several other implementations available for Windows.

HTH

dstromberg
  • 6,954
  • 1
  • 26
  • 27
  • would this code work? I do not have anyware to rdp too, so I cant check. from subprocess import Popen key = raw_input("Enter the IP you want to rdp too \n") Popen(["mstsc.exe", key],) –  Jan 18 '14 at 22:41
0

As per this GitHub comment, you can try to use libfreerdp via ctypes in Python.

See: FreeRDP library at GitHub which is a free remote desktop protocol library and clients.

Home page: www.freerdp.com

Related: Programmatically manipulating active RDP session.

kenorb
  • 155,785
  • 88
  • 678
  • 743