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.
Asked
Active
Viewed 312 times
1
-
possible duplicate: http://superuser.com/questions/362152/native-alternative-to-wget-in-windows-powershell – mnmnc Apr 02 '13 at 00:45
-
1Any restriction that prevents you from using wget, curl and so on? – Karan Apr 02 '13 at 00:56
1 Answers
2
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? – nate302 Apr 02 '13 at 00: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? – Vincent Apr 02 '13 at 00: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) – nate302 Apr 02 '13 at 00:59
-
I believe it is possible to install PowerShell on server 2008: http://www.tech-recipes.com/rx/2521/windows_server_2008_install_windows_powershell/ or http://technet.microsoft.com/en-us/library/hh847837.aspx Would that be an option for you? – Vincent Apr 02 '13 at 01: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. – nate302 Apr 02 '13 at 01:07