0

I am working on a HTA with VBScript, I am having trouble getting download progress from WGet or Aria2.

I have attempted to extract it from STDOUT with the following code, but it is giving me gibberish instead of the download bar to parse.

Const WshRunning = 0
Const WshFinished = 1
Const WshFailed = 2
Dim WshShellExec, Interval

Sub LaunchProcess
                Cmd = "get/wget -O- http://cachefly.cachefly.net/100mb.test"
                Set WshShellExec = CreateObject("WScript.Shell").Exec(Cmd)
Interval = window.setInterval(GetRef("UpdateStatus"),500)
End Sub    

Sub UpdateStatus
Dim status 
Set Status = Document.GetElementByID("Status")

Select Case WshShellExec.Status
    Case WshRunning
                    status.InnerHTML = WshShellExec.StdOut.ReadLine()
    Case WshFinished, WshFailed
                    status.InnerHTML = Replace(WshShellExec.StdOut.ReadAll(),vbCRLF,"<br>")
                    status.InnerHTML = "Done"
        window.clearInterval(Interval)
        Interval = Empty
End Select
End Sub                

Not sure where I am going wrong? Or there alternate methods I could use? All I'm really after is a method to download a file and update a loading bar via percentage. Is that impossible within a HTA with VBScript or Javascript?

Thanks

Ctrlaltdenied
  • 139
  • 3
  • 11
  • 1
    Use XMLHTTPRequest instead. Also you don't have to use VBS in HTAs, you can use JScript too and use the exact same objects. – Dai Oct 04 '15 at 20:26
  • Does XMLHTTPRequest allow download percentage to be calculated and shown? – Ctrlaltdenied Oct 04 '15 at 20:33
  • Yes, it has properties that display activity progress. – Dai Oct 04 '15 at 22:03
  • Would you please supply an example of such with percentage and any other download metric as an example so I can adjust it for my use? – Ctrlaltdenied Oct 05 '15 at 17:38
  • Here is an example: http://stackoverflow.com/questions/76976/how-to-get-progress-from-xmlhttprequest – Dai Oct 05 '15 at 18:41

0 Answers0