Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何使用MS-DOS命令模拟curl?_Windows_Curl_Command Line - Fatal编程技术网

Windows 如何使用MS-DOS命令模拟curl?

Windows 如何使用MS-DOS命令模拟curl?,windows,curl,command-line,Windows,Curl,Command Line,我正在编写一个跨平台的应用程序,教人们如何使用命令行。我想向他们展示如何打印出URL的HTML内容。通常,我会使用curl,但是Windows没有这个程序,我不希望我的用户必须安装任何额外的程序 有没有一种方法可以使用内置MS-DOS命令来模拟curl,或者将一段VBScript发送到wscript进行评估?用户在Windows上至少有两种可能: 1) 下载curl for windows build(在上搜索),其中一些是单个curl.exe文件(或者可能带有一些ssl dll),因此无需安装

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


有没有一种方法可以使用内置MS-DOS命令来模拟curl,或者将一段VBScript发送到
wscript
进行评估?

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

1) 下载curl for windows build(在上搜索),其中一些是单个curl.exe文件(或者可能带有一些ssl dll),因此无需安装,您可以复制到system32或添加到PATH

2) 安装powershell并使用相应的.net对象执行以下操作:

如果安装了.net,您可以使用批处理文件创建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用户安装cygwin;)还有一个windows版本的
wget
,它的功能与
curl
重叠。可能重复的>我不希望我的用户必须安装任何额外的程序。-那么这就是你问题的答案。我只是认为复制curl不是安装,PowerShell是现代的Windows shell,鼓励用户使用它而不是cmd.:)我想避开“cls”,但我还没有找到一种方法。如果您使用它,您将看到“cls”隐藏了一条丑陋但温和的错误消息:
“/*”未被识别为内部或外部命令