Download File with IE

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 2 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #46558
    Profile photo of Neeraj Pandey
    Neeraj Pandey
    Participant

    Hi,

    I am trying to download a file from a website I am able to download it

    ($iexplorer.Document.getElementById('ctl00_ph1_rv_up_tcPM_CtrlTabHeader_fvReq_ctlFileID_ctlFileID_cmdName')).click()

    now comes a save as popup at bottom of IE and this is how I am handling it as of now, using WASP.dll

    Select-Window iexplore |Set-WindowActive |Select-ChildWindow -Passthru |Send-Keys "%{s}"

    this saves the file.
    I want to make my code wait till the file completely gets downloaded and get the filename that it shows in saveas box.
    Suggestions please.

    Thanks

    • This topic was modified 2 months, 2 weeks ago by Profile photo of Neeraj Pandey Neeraj Pandey.
    #46742
    Profile photo of Don Jones
    Don Jones
    Keymaster

    You probably can't. The old IE COM object doesn't provide that kind of callback to let your code know the download is done. And there's nothing native in PowerShell to do this; what people will usually do is instantiate a WebRequest object in .NET and request the specific file from the web server. The .NET class provides asynchronous callbacks, meaning you provide a chunk of code to run once the download is done. There are some third-party modules that work similarly. But that IE COM object is over a decade old, isn't updated anymore (it's officially deprecated, and it'll probably start to go away with the shift to Edge), and just doesn't provide a lot of advanced functions.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.