Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

AutoIT running in RDP sessions


  • Please log in to reply
10 replies to this topic

#1 LiorTal

LiorTal

    Seeker

  • Active Members
  • 7 posts

Posted 03 April 2011 - 07:18 AM

Hello all,

Recently i've encountered some issues with an automated process i am building that involves AutoIT.

I am running the compiled AutoIt executable on a remote machine, connected via RDP.

It appears, that when the RDP window (using mRemote to perform RDP connections) is minimized or closed, the whole execution flow will halt, and all the AutoIT commands are not being executed.

I've looked around the forums and in Google a little bit, but haven't found any conclusive information or a good workaround for this issue (besides keeping the window always opened).

This makes using AutoIT not consistent and robust as it may be.

Any solutions for this scenario ? How can we avoid this ?

Thanks!
Lior

Edit:
I wrote a small test application that prints DateTime.Now every 2 seconds. This works, even when disconnecting from the RDP session.

This means that arbitrary C# code works even when RDP session is disconnected; however, AutoIT code does not.

Edited by LiorTal, 03 April 2011 - 07:32 AM.








#2 Aktonius

Aktonius

    Prodigy

  • Active Members
  • PipPipPip
  • 198 posts

Posted 03 April 2011 - 08:17 AM

Hello all,

Recently i've encountered some issues with an automated process i am building that involves AutoIT.

I am running the compiled AutoIt executable on a remote machine, connected via RDP.

It appears, that when the RDP window (using mRemote to perform RDP connections) is minimized or closed, the whole execution flow will halt, and all the AutoIT commands are not being executed.

I've looked around the forums and in Google a little bit, but haven't found any conclusive information or a good workaround for this issue (besides keeping the window always opened).

This makes using AutoIT not consistent and robust as it may be.

Any solutions for this scenario ? How can we avoid this ?

Thanks!
Lior

Edit:
I wrote a small test application that prints DateTime.Now every 2 seconds. This works, even when disconnecting from the RDP session.

This means that arbitrary C# code works even when RDP session is disconnected; however, AutoIT code does not.


Afaik some remote tasks like windows remote control works by grabbing your entire system so if you use the system it will halt on the remote machine.

Maybe that could give you some clues

#3 LiorTal

LiorTal

    Seeker

  • Active Members
  • 7 posts

Posted 03 April 2011 - 08:23 AM

Afaik some remote tasks like windows remote control works by grabbing your entire system so if you use the system it will halt on the remote machine.

Maybe that could give you some clues


I am not doing a remote window control.

I am connected via RDP to some machine, and running an .exe file with my script there locally.

#4 Bowmore

Bowmore

    Feinschmecker

  • Active Members
  • PipPipPipPipPipPip
  • 833 posts

Posted 03 April 2011 - 11:13 AM

If your AutoIt script uses any of the GUI automation function then it will stop working when you disconnect the RDP session. This is because RDP always locks the remote desktop on disconnect so there is no GUI available for AutoIt to automate. The way round this is to use something like VNC to connect to the remote PC as this can be configured to leave the remote desktop unlocked when you disconnect.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

#5 LiorTal

LiorTal

    Seeker

  • Active Members
  • 7 posts

Posted 03 April 2011 - 12:09 PM

I am not doing a remote window control.

I am connected via RDP to some machine, and running an .exe file with my script there locally.


There appears to be a simple solution:

http://blog.smartbear.com/post/10-10-11/testcomplete-tip-running-tests-in-minimized-remote-desktop-windows/?printable=1

check it out !

#6 Bowmore

Bowmore

    Feinschmecker

  • Active Members
  • PipPipPipPipPipPip
  • 833 posts

Posted 03 April 2011 - 12:47 PM

That fix only works for a minimised RDP connection. If you disconnect the RDP session the GUI automation exe running on the remote PC will be stopped by RDP locking the desktop on the remote PC. This affects all widows GUI automation software, not just AutoIt. Autoit scripts that do not directly interact with the GUI will continue to work. If you avoid using functions such as WinActivate(), Send(), MouseClick() etc. and instead use WinExists(), ControlSend(), ControlClick() you may still be able to get your script to continue running with a locked desktop. This method will not work if the window or control has been configured to only accept input when it has focus.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

#7 arpan

arpan

    Seeker

  • Active Members
  • 11 posts

Posted 29 April 2011 - 06:26 AM

Well so no other way to work on disconnected RDP?
Perl allows you to access controls , send keys, press button on closed RDP also.
I would be happy to do it with AutoIT instead of Perl.

#8 omikron48

omikron48

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 796 posts

Posted 29 April 2011 - 08:50 AM

Which parts of your code fail? If it's MouseClick or Send, you need to replace them with ControlClick and ControlSend so they keep working even if the computer is locked.

I'm not sure with what happens you get disconnected to a remote session in RDP on a server class OS (Windows Server 2003/2008), since there's more than one active session (console and remote) as opposed to only one session (console only) active with desktop ones (XP, Vista, Win7). I'm not even certain if what kind of remote session you are using is a factor with automating within a disconnected session.

What I can say is that I have successfully done software installations, even on disconnected sessions (when connection drops) via using ControlSend and ControlClick on the program installation wizard on Windows XP.

#9 arpan

arpan

    Seeker

  • Active Members
  • 11 posts

Posted 04 May 2011 - 09:07 AM

Which parts of your code fail? If it's MouseClick or Send, you need to replace them with ControlClick and ControlSend so they keep working even if the computer is locked.

I'm not sure with what happens you get disconnected to a remote session in RDP on a server class OS (Windows Server 2003/2008), since there's more than one active session (console and remote) as opposed to only one session (console only) active with desktop ones (XP, Vista, Win7). I'm not even certain if what kind of remote session you are using is a factor with automating within a disconnected session.

What I can say is that I have successfully done software installations, even on disconnected sessions (when connection drops) via using ControlSend and ControlClick on the program installation wizard on Windows XP.


Omi,
I replaced all winWaitActive(...) by WinActive() removed winActivate(...) calls.
I am using controlSend() instead of send...
Still I am not able to send the clicks or rather autoITscript hands.
This script is just for file download.
Any thoughts across this?

#10 Bowmore

Bowmore

    Feinschmecker

  • Active Members
  • PipPipPipPipPipPip
  • 833 posts

Posted 04 May 2011 - 10:44 AM

Omi,
I replaced all winWaitActive(...) by WinActive() removed winActivate(...) calls.
I am using controlSend() instead of send...
Still I am not able to send the clicks or rather autoITscript hands.
This script is just for file download.
Any thoughts across this?


WinActive will not work either when the PC is locked as no windows other than the lock dialog can have focus when the PC is locked. Try using WinExist() instead adding a small delay after the window exist just to make sure it has had time to create all the controls on the window. This should work, but not always as some controls will sometimes only accept any form of input when the have focus which is not possible when the PC is locked.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

#11 arpan

arpan

    Seeker

  • Active Members
  • 11 posts

Posted 05 May 2011 - 07:39 AM

WinActive will not work either when the PC is locked as no windows other than the lock dialog can have focus when the PC is locked. Try using WinExist() instead adding a small delay after the window exist just to make sure it has had time to create all the controls on the window. This should work, but not always as some controls will sometimes only accept any form of input when the have focus which is not possible when the PC is locked.

Thanks for explanation about winActivate() .
I removed winActivate() from the script but script doesn't work if the download window is not on the top.
I am not able to send the ControlSend or controlClick if the download window is not on the top.
I am not sure if we are missing something here.

I am attaching part of code here:

AutoItSetOption("WinTitleMatchMode","2") WinWait("File Download","",10) $fileDownloadTitle = WinGetTitle("File Download") WinWait($fileDownloadTitle,"",10) ControlClick($fileDownloadTitle,"","Button2") Sleep(300) WinWait("Save","",10) $saveDlgTitle = WinGetTitle("Save") WinWait($saveDlgTitle,"",20) ControlSend($saveDlgTitle,"","Edit1","c:/docs/temp.zip",@SW_ENABLE) ControlClick($saveDlgTitle,"","Button2")

Edited by arpan, 05 May 2011 - 07:50 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users