AutoIt script hangs but only if it is run remotely using mstsc.

rberke used Ask the Experts™
I have two simple workarounds for today's problem, but I am willing to spend an hour looking for a better approach. After that I will give up.

Answers such as "switch from w7/IE8 to w10/IE11" will not be considered.

Our office has a customized windows 7 desktop (named Office1) which is entirely dedicated to running a weekly script named Weekly.au3.

The script uses internet explorer 8 to download hundreds of webpages into a database, so it runs about 8 hours.

Every Saturday morning at home I use my Windows 10 laptop (named MyLaptop) and mstsc to log into the office desktop.  I start the script then go way until Sunday morning when I check for successful completion.

There is one very annoying problem: I must leave the mstsc window opened and maximized on MyLaptop.  

If I minimize the window, or close the window  the Office1 script hangs, and does not resume until I reconnect using mstsc.

I threw in some debugging statements and found that the hang occurs during the _clickIE statment below.   While this code is in AutoIt, I am pretty sure the same problem would occur with AutoHotkey or other scripting tools.

consolewrite(_CurrentTime("-", ":") & "line1"&@CRLF)
consolewrite(_CurrentTime("-", ":") & "line2"&@CRLF)
_ClickIE($WinTitleDownload, "", @OSVersion)
consolewrite(_CurrentTime("-", ":") & "line3"&@CRLF)

My "simple" workaround #1 is to use GotoMyPC to connect instead of MSTSC.
Workaround #2 is to first use mstsc to connect MyLaptop to another office computer named "OfficeMary". Then I "daisy chain" from OfficeMary to Office1.  

There is a very annoying quer
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AntzsInfrastructure Services

Have you tried running mstsc with the /admin switch?


Actually, I always run it with the /admin switch.
AntzsInfrastructure Services

Since you are connecting from home, I would assume you would be using some sort of VPN to connect back to your office.

The next time you are connected and running the script.  Instead of minimizing the remote desktop window, try leaving the remote desktop window at maximum but disconnect the VPN connection instead.  This way the remote desktop window would basically still be open.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).



interesting idea. I will try it from home tonight.  (I am betting it won't work, but easy enough to try,)


no, that did not work.  As soon as I disconnected my laptop the autoit IE downloads stopped.
I even tried hibernating my laptop.  Within 5 second remote desktop _ClickIE command hung.  An hour later I revived my laptop, and reconnected to the the remote desktop.  The _clickIE command immediately  finished normally and processing continued.
Perhaps IE 8 has some sort of dialog with the  virtual monitor.  1) send the screen to the monitor 2) wait for the monitor to acknowledge the send?
I'll leave the question open for a few days, but I have spent 1 hour on this, and any more work will exceed my budget.
AntzsInfrastructure Services

Can you try changing this setting on the Win 7 Machine?


It was already set at 15 minutes. Just for giggles, I tried changing the value to 0, but that did not help.

But don't think that is a relevant setting, because the network session is not suspended -- it is manually terminated by me.

And, Office1 continues running other programs, it is only the _ClickIE that is getting suspended.

To confirm,  I started the AutoIt program and the following excel program at about the same time.
After both programs had run for 3 minutes, I disconnected my laptop by canceling the MSTSC window.
10 minutes later I reconnected:
   The AutoIt log showed that  _clickIE had been suspended for 10 minutes.
   The excel log showed that excel had continue running the whole time.

Sub logit()
' write log file once a minute for 100 minutes
For i = 1 To 100
    Call writeLogFile(150, i & " of 100 log records")
    Sleep (60000)
Next i

End Sub

Open in new window

time to close this problem.  My initially posted workarounds are the best solutions.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial