我怎样才能模仿与MS-DOS命令curl?

我正在编写一个跨平台的应用程序,教人们如何使用命令行。 我想向他们展示如何打印URL的HTML内容。 通常情况下,我会用curl来做这个,但是Windows并没有提供这个程序,我也不希望我的用户需要安装任何额外的程序。

有没有办法使用内置的MS-DOS命令模拟curl,也许发送一个VBScript片段wscript评估?

假设.net已安装,您可以将 c#与批处理文件结合使用以创建wget.cmd:

 /* @echo off && cls if '%2'=='' ( echo usage: %0 url filename goto :eof ) set WinDirNet=%WinDir%\Microsoft.NET\Framework IF EXIST "%WinDirNet%\v2.0.50727\csc.exe" set csc="%WinDirNet%\v2.0.50727\csc.exe" IF EXIST "%WinDirNet%\v3.5\csc.exe" set csc="%WinDirNet%\v3.5\csc.exe" IF EXIST "%WinDirNet%\v4.0.30319\csc.exe" set csc="%WinDirNet%\v4.0.30319\csc.exe" %csc% /nologo /out:"%~0.exe" %0 "%~0.exe" "%1" "%2" del "%~0.exe" goto :eof */ using System; using System.Net; using System.IO; class MyWget { static void Main(string[] args) { WebClient wc = new WebClient(); wc.DownloadFile(args[0],args[1]); } } 

用户在Windows上至少有两种可能性:

1)下载curl-for-windows build(在http://curl.haxx.se/download.html上搜索它),其中一些作为单个curl.exe文件(或者可能与一些ssl dll的)不需要安装,你可以复制到system32或添加到PATH

2)安装powershell,并使用相应的.net对象来做这件事情: http : //answers.oreilly.com/topic/2006-how-to-download-a-file-from-the-internet-with-windows-powershell /