Download File with IE


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

  • Author
  • #46558
    Profile photo of Neeraj Pandey
    Neeraj Pandey


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


    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.


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

    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.

You must be logged in to reply to this topic.