1

I'm wanting to create an automated job in Windows (presumably using Task Scheduler) to copy a CSV file from a URL to my desktop. From what I can gather, a batch file cannot copy a file from an external location. Not familiar with Powershell, but it looks like it might have that capability.

What is the best way to create a script and automate the process to copy a file (http://example.com/file.csv) to my Desktop for instance? Would like to use features native to Windows without having to download a third-party application if possible.

Thanks for any and all help!

ad2387
  • 551
  • 2
  • 11
  • 21
  • You can look here: http://stackoverflow.com/questions/1973880/download-url-content for an example using WebClient to download the file in powershell. – dugas Mar 04 '15 at 19:57

3 Answers3

2

You can download a file using powershell using syntax like this:

$client = new-object System.Net.WebClient
$client.DownloadFile("http://example.com/file.csv","C:\tmp\file.txt")

Save this as a script (something.ps1). Then create a task in the Task Scheduler and add a new "Action" of the type Open Program. Use program PowerShell, and specify the path to the script (like C:\something.ps1) as the argument.

More info:

Community
  • 1
  • 1
Márcio Paiva
  • 983
  • 9
  • 25
1

Windows Scripting Host does allow you to get files via HTTP.

See AnthonyWJones' answer at HTTP GET in VBS

Change code as appropriate, save as .vbs file, schedule same.

Community
  • 1
  • 1
0

I know very little about powershell so I don't know if it can do it. I know you prefer not to use a third-party application, but you can easily do what you want with curl which comes as a single stand-alone exe: http://curl.haxx.se/dlwiz/

Sebastiaan M
  • 5,775
  • 2
  • 27
  • 28