如何 post 一个文件或标准输出到一个http服务器?

how to post a file or stdout into a http server?

我想执行一些命令然后将它们发送到我的网络服务器进行分析。

有点像:

wmic csproduct get | wget http://someserver/cgi-bin/hello.pl

除了 wget 不是 Microsoft 开箱即用的。

如何使用 Windows 2000 及以后的产品提供相同的东西? vbscript 可以完成这项工作吗?

既然你执行了一些命令来获取你的信息,使用命令 shell 环境会不会更原生? PowerShell 怎么样?

(New-Object System.Net.WebClient).UploadString("http://someserver/cgi-bin/hello.pl", (Get-WMIObject Win32_BIOS) )

read about the UploadString() method here

如果您仍然想坚持使用 vbscript 解决方案,这里是一个示例代码,它接受来自标准输入的文本并将其发布到您的服务器:

Dim inp, http_req
inp = inp & WScript.StdIn.ReadAll()
WScript.Echo "Input: " & inp

Set http_req = CreateObject("WinHTTP.WinHTTPRequest.5.1")
http_req.open "POST", "http://someserver/cgi-bin/hello.pl", false
http_req.setRequestHeader "Content-Type", "text/plain"
http_req.send inp

The minimum requirements seems to be Windows 2000 Professional with SP3 ,我用 Windows XP 亲自测试了脚本。