Kumar Vikramjeet Kumar Vikramjeet - 1 year ago 90
Ruby Question

Chef inspec test for testing a path presence in %PATH%

I want to check whether a path has been added in windows %PATH% environment variable, using inspec test in Chef. I'm not able to find any hints online.

describe command('echo %PATH%') do
its('stdout') { should match /C:\SoftwareX\bin/ }

It's not working. Appreciate any help!

Answer Source

echo is not a program, it's a cmd.exe built-in. Try command('cmd.exe /c "echo %PATH%"') or similar. You could also use a copy of env built for windows if you have one on the machine already.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download