Jump to content

AutoIT running in RDP sessions


Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...