Is there a windows equivalent of Linux's "get" command in windows that I can use to obtain remote objects? I want to be able to have a batch file download a remote file on execution.
1 Answer
Assuming you use windows powershell, is this what you are looking for:
If you just need to retrieve a file, you can use the DownloadFile method of the WebClient object:
$client = new-object System.Net.WebClient
$client.DownloadFile( $url,$path )
Where $url is a string representing the file's URL, and $path representing the local path the file will be saved to.
Note that $path must include the file name; it can't just be a directory.
Comes from this topic: Native alternative to wget in Windows PowerShell?
-
This is just a batch file run from an elevated command prompt. Will this work in a plain old command prompt?– nate302Apr 2, 2013 at 0:50
-
I don't think it will run in the CMD that comes with XP/Vista. From Win7 onwards, PowerShell comes out of the box. If you don't have PowerShell and you are familiar with unix shell script, why not try Cygwin?– VincentApr 2, 2013 at 0:57
-
It's a server 2008 r2 box and I've not seen Cygwin. Is there a way without using Cygwin? (get is probably the only linux command I'd be using)– nate302Apr 2, 2013 at 0:59
-
I believe it is possible to install PowerShell on server 2008: tech-recipes.com/rx/2521/… or technet.microsoft.com/en-us/library/hh847837.aspx Would that be an option for you?– VincentApr 2, 2013 at 1:03
-
I have powershell, I may just write a small program for it instead as I'd like it to work on windows systems without powershell as well.– nate302Apr 2, 2013 at 1:07