minisch
minisch

Reputation: 343

Writing Windows batch Chef recipe

I have not done chef before. Does the following code look correct?

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

The command is to silently install SInstaller.exe

Upvotes: 0

Views: 579

Answers (1)

deem
deem

Reputation: 1252

I would recommend you using powershell_script instead

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

This script runs new instance of cmd process and runs command C:\bootstrap\SInstaller.exe /S /APIKEY=hththfthtfdh in it.

For me, batch is sometimes a little buggy.

Try using it and tell me if it works!

If you still prefer using batch resource, you have to write paths with \, like C:\\bootstrap\\SInstaller.exe /S /APIKEY=hththfthtfdh or you will have error

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

Rest of your code seems OK to me.

Upvotes: 1

Related Questions