Im trying to reproduce the following batch file but on command-line oneliner. Id like to be able to use this client in python scripts and to identify if a connection is made I need to be able to retrieve the error codes. I am calling the application via subprocess Any help would be appreciated
BATCH FILE CODE
ECHO OFF START /WAIT rdp.exe /v:192.168.1.122 /u:xpuser /p:xpuser /batch ECHO %ERRORLEVEL% I have tried the below commands along with many variations but cant get what is expected. Information on the executable can be found here
EXAMPLE
c:\Python27>start /WAIT rdp.exe /v:192.168.1.122 /u:xpuser /p:xpuser /log /batch | ECHO %ERRORLEVEL% c:\Python27>start rdp.exe /v:192.168.1.122 /u:xpuser /p:xpuser /batch || ECHO %ERRORLEVEL% SNIPPET OF PYTHON CODE
try: cmdrdp = "rdp.exe /v:%s /u:%s /p:%s /log /batch" % (server, username, password) subprocess.check_output(cmdrdp) except CalledProcessError as e: print(e.returncode) else: print "Connected to: %s %s %s" % (server, username, password)