0

I upgraded to Windows 10 a few days ago and I have not been able to get one of my scripts to work. This simple stand-alone script demonstrates the problem:

$erroractionpreference = "Continue"   
$ie = New-Object -ComObject InternetExplorer.Application
$ie.visible = $True

$url = "http://gtr1.backtest.org/2013/?sp500.a:et1"

$ie.Navigate($url)
while ($ie.busy) {Start-Sleep 1}
$backtest = $ie.document.getElementsByName("submit") |
            Where-Object {$_.value -eq "Run Backtest"}
$backtest.click()  #shows SP500 backtest results
while ($ie.busy) {Start-Sleep 1}
$screener = $ie.document.getElementsByName("submit") |
            Where-Object {$_.value -eq "Run Screener"}
$screener.click()  #shows list of SP500 stocks
while ($ie.busy) {Start-Sleep 1}

The program navigates to a stock backtesting website with a simple screen, clicks on the "run backtest" button, and this part works fine; I can watch the progress in the visible IE session. What SHOULD happen is that the "run screener" button is then clicked and a list of SP500 stocks is shown.

But the updated (after the first click) website information does not come back to the script, apparently. Once or twice I saw an RPC DISCONNECTED type error but I can't reproduce it. This is the usual error message:

Exception from HRESULT: 0x800A138A
At C:\Users\MD\OneDrive\Documents\Mechanical Investing\GTR1\Daily Runs\Temp1.ps1:12 char:1
+ $screener = $ie.document.getElementsByName("submit") | Where-Object { ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

So the initial navigation to the website, and first button click work fine, but the second one doesn't. It doesn't matter whether I'm running as Administrator or not, and it doesn't work at the command prompt. I had a similar script to this running for quite a long time on Windows 7 with no issues. I did add PowerShell as an allowed app in the firewall settings but that didn't help.

Any ideas?

Matt
  • 45,022
  • 8
  • 78
  • 119
Mark
  • 19
  • 1
  • 3
  • The attempted troubleshooting in your title was misleading people. I renamed it to hopefully be something more appropriate. – Matt Jan 04 '16 at 16:46
  • Does it change if you change the sleep limit to something higher like 3-5 seconds? It is possible that Windows 10 is not the issue as well. Does this script work on other machines? – Matt Jan 04 '16 at 16:49
  • Thanks Matt. I did try increasing the sleep limit with no change. And no, I don't have another machine right here to try it on. I wondered if it's a non-Win10 issue, but I had a very similar script running for year on this same computer with Win7, and after the upgrade I've had exactly this problem. So I suspect some firewall type issue but could be wrong. Win10 also comes with Powershell 5.0 and before I had 4.0 IIRC. – Mark Jan 04 '16 at 16:56
  • The seconds suggestion was silly anyway (1 second is preferable). Are you able to disable your firewall for testing to either include or exclude that as a source of the issue? – Matt Jan 04 '16 at 17:02
  • Yes I did disable the firewall just now and there is no change. I didn't restart the computer but did restart Powershell. That implies that the firewall is not involved, but I can't figure out what else would be the issue, – Mark Jan 04 '16 at 17:09
  • 3
    [PowerShell change list](https://technet.microsoft.com/en-us/library/hh857339.aspx#BKMK_5bugfix) claims: *Windows PowerShell 5.0 includes a new COM implementation, which offers significant performance improvements when you are working with COM objects.* Maybe it somehow related to your issue. – user4003407 Jan 04 '16 at 17:29

1 Answers1

1

I had the same error and adding a key to regedit fixed it. It's discussed here in the link below.

Powershell Web Page Automation works on Internet, not Intranet

Community
  • 1
  • 1
robb
  • 11
  • 1
  • Welcome to Stack Overflow! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Enamul Hassan Apr 15 '16 at 17:59