mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
bugfix: catch cases, where no service is available
This commit is contained in:
parent
04ca75b6e7
commit
5019664d4d
1 changed files with 5 additions and 2 deletions
|
@ -311,8 +311,11 @@ class WindowsSrv < ServiceManager
|
|||
return nil
|
||||
end
|
||||
|
||||
service['Service']['Status'] == 4 ? (running = true) : (running = false)
|
||||
service['WMI']['StartMode'] == 'Auto' ? (enabled = true) : (enabled = false)
|
||||
# check that we got a response
|
||||
return nil if service.nil? || service['Service'].nil?
|
||||
|
||||
(!service['Service'].nil? && !service['Service']['Status'].nil? && service['Service']['Status'] == 4) ? (running = true) : (running = false)
|
||||
(!service['WMI'].nil? && !service['WMI']['StartMode'].nil? && service['WMI']['StartMode'] == 'Auto') ? (enabled = true) : (enabled = false)
|
||||
|
||||
{
|
||||
name: service['Service']['Name'],
|
||||
|
|
Loading…
Reference in a new issue