Author Topic: What is the Future of Winbatch / IE / OLE Programming?  (Read 1125 times)

mcjathan

  • Newbie
  • *
  • Posts: 42
What is the Future of Winbatch / IE / OLE Programming?
« on: September 09, 2019, 03:15:15 pm »
Unless I'm mistaken, Internet Explorer will be phased out (after Windows 10?).  If I've missed this conversation somewhere else in this forum, would someone please point me there?

Otherwise, what are fellow Winbatch users' plans to transition their Winbatch scripts to other browsers or tools?

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #1 on: September 09, 2019, 04:52:20 pm »
I have been experimenting with C# and the WebBrowser control.   Of course one can use that in WinBatch but it tends to lock up at times unless one initiates a Display(), Message(), etc. which isn't ideal and sometimes quite problematic.   With C# the DoEvents() clears the pipeline so things proceed.

Jim

td

  • Tech Support
  • *****
  • Posts: 3952
    • WinBatch
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #2 on: September 09, 2019, 07:39:22 pm »
Unless I'm mistaken, Internet Explorer will be phased out (after Windows 10?).  If I've missed this conversation somewhere else in this forum, would someone please point me there?

Otherwise, what are fellow Winbatch users' plans to transition their Winbatch scripts to other browsers or tools?

Windows 10 is going to be around for a while and Internet Explorer ( the executable Web browser) is going to be available in it according to the MSFT's IE product life cycle.  But that really isn't the point.  COM Automation and the HTTP/HTML/DOM COM Automation interfaces used in many WinBatch scripts is deeply embedded into the OS  so even if IE the browser goes away, MSFT isn't going to remove those objects and their interface unless they did something very radical like completely dumping Windows and switching to the Linux kernel. 

Given that MSFT's IE replacement, the Edge browser, uses Google's Chrome rendering engine already, I guess that isn't completely out of the realm of possibility but the loss of IE would be the least of the issues that kind of radical change would generate.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

  • Tech Support
  • *****
  • Posts: 3952
    • WinBatch
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #3 on: September 09, 2019, 07:42:41 pm »
I have been experimenting with C# and the WebBrowser control.   Of course one can use that in WinBatch but it tends to lock up at times unless one initiates a Display(), Message(), etc. which isn't ideal and sometimes quite problematic.   With C# the DoEvents() clears the pipeline so things proceed.

Jim

Using Display or Message to "clear the pipeline" was an old kludge that should no longer be necessary.  If you can provide an example that requires that approach we will look into it.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #4 on: September 09, 2019, 07:48:14 pm »
Maybe I need to go back and try again???   I think I switched everything that had that problem to automate IE directly so as to avoid such issues.   Will let you know if I see that again.  Thanks.

Jim

mcjathan

  • Newbie
  • *
  • Posts: 42
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #5 on: July 06, 2021, 01:43:08 pm »
I just learned from a vendor who uses IE that Microsoft is dropping support for IE on June 15 2022.  We have a number of operational Winbatch scripts that use IE OLE programming.  I'm looking for a direction to take these Winbatch scripts.  Suggestions?

td

  • Tech Support
  • *****
  • Posts: 3952
    • WinBatch
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #6 on: July 06, 2021, 05:24:47 pm »
It all depends on what you are using IE COM Automation for. While IE the application may be going away many of the Web-related COM Automation objects are not.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mcjathan

  • Newbie
  • *
  • Posts: 42
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #7 on: July 08, 2021, 08:19:27 am »
What our current Winbatch / IE / OLE scripts are doing is logging into a website, and then downloading file / documents, and then logging off.  Is there a way to do this without IE?

td

  • Tech Support
  • *****
  • Posts: 3952
    • WinBatch
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #8 on: July 08, 2021, 10:10:59 am »
Yes but the degree of difficulty depends on the Website. If the site HTML elements you need to perform the task do not involve the execution of javascript, the solution is relatively simple. You could use the aforementioned COM Autionation objects, the Inet WIL extender, or WIL CLR hosting. There are examples of all these techniques on this forum and in the Tech Database.

If you need to execute javascript then it can get complicated. You will need to use some third-party software whether that is automating a Web browser or some HTML testing/scraping tool.  If you search this forum, you will find several discussions on this topic. But since I tend to rely on Website APIs for that kind of task, I can't offer any more specific advice or recommendations. Perhaps another forum user will chime in.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

  • Pundit
  • *****
  • Posts: 1573
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #9 on: July 08, 2021, 11:28:02 am »
Perhaps another forum user will chime in.


Selenium comes to mind

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #10 on: July 08, 2021, 12:22:00 pm »
If the browser control doesn't go away then you may be good with embedding "Shell.Explorer.2" in a dialog.   Easy enough to test now before the IE option goes away.

While pricey, WebKitX, might be an option, if you need a full-blown browser control that handles Javascript.

Jim

....IFICantBYTE

  • Full Member
  • ***
  • Posts: 125
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #11 on: July 11, 2021, 01:41:59 am »
For automating Edge, and other Chrome based browsers "without installing anything", check out this project I came across, and the underlying CDP stuff it uses...

I'm sure someone could get this going in Winbatch.

Simple Project: https://www.codeproject.com/Tips/5307593/Automate-Chrome-Edge-using-VBA
JASON parsing code it uses : https://github.com/VBA-tools/VBA-JSON
Chrome Dev Tools Protocol:  https://chromedevtools.github.io/devtools-protocol/
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

stanl

  • Pundit
  • *****
  • Posts: 1573
Re: What is the Future of Winbatch / IE / OLE Programming?
« Reply #12 on: July 11, 2021, 04:26:16 am »
I wouldn't discount Excel/Power Query for web scraping and content forming. Below uses another pretty interesting URL:
Code: Winbatch

;Winbatch 2021c - Testing Excel Power Query for simple Web Scrape
;Requires Excel 2016 or Higher or Power Query added to Excel 2013 or earlier
;Stan Littlefield July 11, 2021
IntControl(73,1,0,0,0)
gosub udfs
qry = "Raleigh" ;gets city for URL's weather; also is tab name in Excel
cn = "Query - ":qry
mcode = getmcode()
BoxOpen("Please Wait","Creating Excel Power Query for Web Data")
toExcel()
BoxShut()
Pause("Query Completed","Save Workbook or Quit Excel")


Exit
;======================================================================================================
:WBERRORHANDLER
Terminate(@TRUE,"Error Encountered",geterror())
;======================================================================================================
:CANCEL
Display(2,"Operation Canceled","Goodbye...")
Exit
:udfs
#DefineSubRoutine geterror()
   wberroradditionalinfo = wberrorarray[6]
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
   Return(errmsg)
#EndSubRoutine


#DefineSubRoutine getmcode()
;M Code could be loaded from text file
;but if using WB's multi line, special chars must be escaped
code = $"
let
    Source = Web.Page(Web.Contents("https:://www.timeanddate.com/weather/usa/|city|")),
    Data0 = Source{0}[Data]
in
    Data0
$"

code = StrReplace(code,"|city|",qry)
Return(code)
#EndSubRoutine


#DefineSubRoutine toExcel()
oXL = CreateObject("Excel.Application")
If oXL == 0 Then Terminate(@TRUE,"Script Will Terminate","Cannot Start Excel Instance")
oXL.Visible          = @TRUE  ; change this to @FALSE to run hidden
oXL.ScreenUpdating   = @TRUE  ; if running hidden, change this to @FALSE
oXL.UserControl      = @TRUE
oXL.DisplayAlerts    = @FALSE
oXL.WorkBooks.Add()
oWS = oXL.ActiveWorkBook.Worksheets(1)
oWS.Activate()
oWS.Name = qry
oXL.ActiveWorkBook.Queries.Add(::Name=qry,Formula=mcode,Description="Json Query")
cSource = "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=%qry%;Extended Properties=''"
qt = oWS.ListObjects.Add(::SourceType=0,Source=cSource,Destination=oWS.Range("$A$1")).QueryTable
qt.CommandText = "Select * FROM [%qry%]"
qt.Refresh()
;may take some time but should save
;oXL.ActiveWorkbook.SaveAs(cXLS)
;oXL.ActiveWorkbook.Close()
;oXL.Quit()
oWS=0
oXL=0
Return(1)
#EndSubRoutine




Return