2

I'm trying to perform a one-liner file download in Windows command line, without depending on external tools like WGET, or even writing PowerShell or VBScripts scripts.

I tried to run

c:\> RunDLL32.exe URLMon.dll,URLDownloadToFIle 0,"http://www.example.com/file.pdf" "c:\\MyName\\Downloads\\",0

It didn't work.
What did I do wrong? Or would that even work?

Norbert Willhelm
  • 2,579
  • 1
  • 23
  • 33
xyz
  • 870
  • 2
  • 8
  • 16

1 Answers1

5

The function URLDownloadToFile has the following signature:

HRESULT URLDownloadToFile(
         LPUNKNOWN            pCaller,
         LPCTSTR              szURL,
         LPCTSTR              szFileName,
         DWORD dwReserved,
         LPBINDSTATUSCALLBACK lpfnCB
         );

Functions callable by rundll32.exe need to have the following function prototype:

void CALLBACK  EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);

You aren't able to use rundll32.exe to run URLDownloadToFile, because these two prototypes are incompatible.

Norbert Willhelm
  • 2,579
  • 1
  • 23
  • 33