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

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AntzsInfrastructure ServicesCommented:
Have you tried running mstsc with the /admin switch?
rberkeConsultantAuthor Commented:
Actually, I always run it with the /admin switch.
AntzsInfrastructure ServicesCommented:
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.
5 Ways Acronis Skyrockets Your Data Protection

Risks to data security are risks to business continuity. Businesses need to know what these risks look like – and where they can turn for help.
Check our newest E-Book and learn how you can differentiate your data protection business with advanced cloud solutions Acronis delivers

rberkeConsultantAuthor Commented:
interesting idea. I will try it from home tonight.  (I am betting it won't work, but easy enough to try,)
rberkeConsultantAuthor Commented:
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 ServicesCommented:
Can you try changing this setting on the Win 7 Machine?
rberkeConsultantAuthor Commented:
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

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.