编写Windows批量厨师食谱

时间:2015-08-05 05:39:51

标签: chef

我之前没有做过厨师。以下代码看起来是否正确?

batch 'windows_batch' do
    code <<-EOH
          C:\bootstrap\SInstaller.exe /S /APIKEY=hththfthtfdh
    EOH
end

该命令是以静默方式安装SInstaller.exe

1 个答案:

答案 0 :(得分:1)

我建议您使用powershell_script代替

powershell_script 'windows_batch' do
    code <<-EOH
        Start-Process "cmd.exe"  "/c C:\\bootstrap\\SInstaller.exe /S /APIKEY=hththfthtfdh"
    EOH
end

此脚本运行cmd进程的新实例,并在其中运行命令C:\bootstrap\SInstaller.exe /S /APIKEY=hththfthtfdh

对我而言,batch有时候是一辆小车。

尝试使用它并告诉我它是否有效!

如果您仍然喜欢使用batch资源,则必须使用\编写路径,例如 C:\\bootstrap\\SInstaller.exe /S /APIKEY=hththfthtfdh或您将收到错误

Invalid escape character syntax
      C:\bootstrap\SInstaller.exe /S /APIKEY=hththfthtfdh
                   ^

其余的代码对我来说似乎没问题。