Tuesday, April 16, 2013

wget alternative in windows command line


Run the PowerShell V1.0 script directly in command line:
cmd> PowerShell -Command "(new-object System.Net.WebClient).DownloadFile( 'http://download.microsoft.com/download/2/0/E/20E90413-712F-438C-988E-FDAA79A8AC3D/dotnetfx35.exe', 'D:\dotnetfx35.exe')"

Run the PowerShell V1.0 script from a file:
PowerShell -Command "& {c:\users\john\myscript.ps1}"

myscript.ps1:
$client = new-object System.Net.WebClient
$client.DownloadFile( $url, $path )

or myscript.ps1 in one line:
(new-object System.Net.WebClient).DownloadFile($url, $path)

or myscript.ps1 in PowerShell V3.0:
Invoke-WebRequest http://www.google.com/ -OutFile c:\google.html

or myscript.ps1 in PowerShell V3.0:
Invoke-WebRequest http://www.google.com/ > c:\google.html

Run the PowerShell V2.0 script from a file:
PowerShell.exe -File c:\users\john\myscript.ps1

Run Wget for Windows:
http://gnuwin32.sourceforge.net/packages/wget.htm

No comments: