Some issues about launching windows_service

I wrote a small cookbook to install virtualbox on my machine using chocolatey package, the name of the package is VirtualBox and then i want to start the service but it can’t launch it on my machine, here is the resource

windows_service ‘Oracle VM VirtualBox’ do
action :start
provider Chef::Provider::Service::Windows
end
~
FATAL: Chef::Exceptions::JSON::EncodeError: Invalid UTF-8 string ‘#<systemcallerror: windows_service[oracle="" vm="" virtualbox]="" (virtualbox::default="" line="" 13)="" had="" an="" error:="" systemcallerror:="" le="" service="" sp�cifi�="" n�existe="" pas="" en="" tant="" que="" service="" install�.="" -="" openservice:="">’: cannot encode to UTF-8

Are you sure the virtual box installer creates a “Oracle VM VirtualBox” service. Checking one of my own windows boxes where Virtualbox is installed, I don’t see that service or any service looking to be directly related to virtualbox.

yes, indeed so if i want to launch a package that i’ve installed on windows, how can i do it?

It really depends on what you want to do with the package. By using the chocolatey_package resource, you should have VirtualBox installed on the node. That would have installed it to $env:programfiles\oracle\VirtualBox. Thats all probably enough for your recipie. If you wanted to interact with virtualbox, you would use the execute resource to call VBoxManage.exe in the virtualbox directory.

Ok and if i want to install jdk using chocolatey what would be the synthax to set the path?
thanks!

It depends on how the package author created the package. Some may adjust the path and others don’t. As a rule, you want to test how a package alters system state as part of your cookbook authoring process.

Assuming that they did not set the path, you could set this yourself using:

chocolatey_package 'your jdk package' do
  notifies :run, 'powershell_script[set jdk path]', :immediately
end

powershell_script 'set jdk path' do
  action :nothing
  code "[System.Environment]::SetEnvironmentVariable('PATH', '<JDK path>;$env:PATH', 'Machine')"
end