Windows – RoboCopy A File From The Web

batchbatch-filerobocopywindows

Is it possible to download a file from the web using RoboCopy? What would the syntax for that be? Here's what I'm trying:

RoboCopy "http://www.google.com/" "C:\some_folder\" "index.html" /L /V /E /LOG:"C:\some_folder\test_robocopy.log" /R:10 /W:30

The error log is giving me an error that seems to indicate the file is a folder, and also that it's trying to hit http://www.google.com as a folder on my location machine.

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Tue Jan 08 10:31:04 2013

   Source : C:\some_folder\http:\www.google.com\index.html\
     Dest : C:\some_folder\index.html\

    Files : *.*

  Options : *.* /V /L /S /E /COPY:DAT /R:10 /W:30 

------------------------------------------------------------------------------

2013/01/08 10:31:04 ERROR 123 (0x0000007B) Accessing Source Directory C:\some_folder\http:\www.google.com\index.html\
The filename, directory name, or volume label syntax is incorrect.

Best Answer

The only way I can conceive of making this work is if you create a WebDAV share, such as the one at live.sysinternals.com, and then address it as a UNC (\\yoursite.com\folder) and the minidirector in the WebClient service will handle it.

But that requires a specific configuration on the web server.

Also, Invoke-WebRequest if you're using PS 3.

Edit: Also make sure the WebClient service is running before trying to access WebDAV shares on the command line. Windows Explorer will start the service on demand, but cmd.exe or powershell.exe will not.