我正在运行以下命令作为 Windows 服务器 Chef 部署的一部分。
cscript /nologo C:\chef\wget.vbs /url:http://www.opscode.com/chef/install.msi /path:C:\Users\ADMINI~1\AppData\Local\Temp\chef-client-latest.msi
我收到的错误是:
CScript Error: Execution of the Windows Script Host failed. (0x800A0007)
vbs 文件由以下命令创建:
C:\Users\Administrator>(
echo.url = WScript.Arguments.Named("url")
echo.path = WScript.Arguments.Named("path")
echo.proxy = null
echo.Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
echo.Set wshShell = CreateObject( "WScript.Shell" )
echo.Set objUserVariables = wshShell.Environment("USER")
echo.
echo.'http proxy is optional
echo.'attempt to read from HTTP_PROXY env var first
echo.On Error Resume Next
echo.
echo.If NOT (objUserVariables("HTTP_PROXY") = "") Then
echo.proxy = objUserVariables("HTTP_PROXY")
echo.
echo.'fall back to named arg
echo.ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then
echo.proxy = WScript.Arguments.Named("proxy")
echo.End If
echo.
echo.If NOT isNull(proxy) Then
echo.'setProxy method is only available on ServerXMLHTTP 6.0+
echo.Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
echo.objXMLHTTP.setProxy 2, proxy
echo.End If
echo.
echo.On Error Goto 0
echo.
echo.objXMLHTTP.open "GET", url, false
echo.objXMLHTTP.send()
echo.If objXMLHTTP.Status = 200 Then
echo.Set objADOStream = CreateObject("ADODB.Stream")
echo.objADOStream.Open
echo.objADOStream.Type = 1
echo.objADOStream.Write objXMLHTTP.ResponseBody
echo.objADOStream.Position = 0
echo.Set objFSO = Createobject("Scripting.FileSystemObject")
echo.If objFSO.Fileexists(path) Then objFSO.DeleteFile path
echo.Set objFSO = Nothing
echo.objADOStream.SaveToFile path
echo.objADOStream.Close
echo.Set objADOStream = Nothing
echo.End if
echo.Set objXMLHTTP = Nothing
) 1>C:\chef\wget.vb
如果我通过 rdp 进入服务器并运行相同的第一个命令,它可以成功运行。
答案1
我发现一个对此的拉取请求已合并到 knife-windows gem 中,但尚未在发布的 gem 中。我通过安装 specific_install gem 并使用它从 github 上的源代码安装解决了我的问题。
gem install specific_install
gem specific_install -l https://github.com/opscode/knife-windows.git