# Registry\_key resource dislikes spaces?

**URL:** https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973
**Category:** Chef Infra (archive)
**Created:** [July 19, 2016, 5:06pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973 "2016-07-19T17:06:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mckownam](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mckownam](https://discourse.chef.io/u/mckownam)
#### Post date: [July 19, 2016, 5:06pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/1 "2016-07-19T17:06:57Z")

</div>

I am trying to use the registry\_key resource on windows in order to identify what type of Symantec is installed on a machine in order to pull down the proper package to upgrade. The registry path includes “Symantec Endpoint Protection”, which results in a registry key does not exist error from chef (the registry entry in question has been confirmed to exist via regedit).

Since I tested out the same code with a registry path that had no spaces and it worked, I’m wondering if the spaces in the path are causing the problem and if so, why is that because the documentation uses examples with spaces. Is this a case in which chef is only looking for a single space and when it hits two, it breaks?

To clarify: I am getting a registry key does not exist error from the registry\_get\_values line in the following portion of my script:  
KEY\_PATH = 'HKEY\_LOCAL\_MACHINE\SOFTWARE\Wow6432Node\Symantec\Symantec Endpoint Protection\SMC\SYLINK\Sylink\CurrentGroup’  
ARCHITECTURE = ':x86\_64’  
reg\_value = registry\_get\_values(KEY\_PATH, ARCHITECTURE)

---

<div class="post-metadata">

### Author: ![Matt\_Wrock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_wrock/32/3394_2.png) [@Matt\_Wrock](https://discourse.chef.io/u/Matt_Wrock)
#### Post date: [July 19, 2016, 7:33pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/2 "2016-07-19T19:33:05Z")

</div>

Are you referring to the registry functions in the recipe DSL or the registry\_key resource? If the latter, what action are you using?

---

<div class="post-metadata">

### Author: ![mckownam](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mckownam](https://discourse.chef.io/u/mckownam)
#### Post date: [July 20, 2016, 1:11pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/3 "2016-07-20T13:11:40Z")

</div>

I clarified it in my edit, but it is the registry\_get\_values() function. Picking a value from the path up to ‘Symantec’ works. Once ‘Symantec Endpoint Protection’ is added, chef just throws “key does not exist” errors.

---

<div class="post-metadata">

### Author: ![Matt\_Wrock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_wrock/32/3394_2.png) [@Matt\_Wrock](https://discourse.chef.io/u/Matt_Wrock)
#### Post date: [July 20, 2016, 7:51pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/4 "2016-07-20T19:51:03Z")

</div>

Out of curiosity I ran `chef-apply` against a file containing:

```auto
KEY_PATH = 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Advanced INF Setup\IE CompList'
ARCHITECTURE = ':x86_64'
reg_value = registry_get_values(KEY_PATH, ARCHITECTURE)
puts reg_value

```

And it seemed to work fine. Not sure why your script is having issues. I’m assuming based on your other info that running:

```auto
Test-Path 'HKLM:\SOFTWARE\Wow6432Node\Symantec\Symantec Endpoint Protection\SMC\SYLINK\Sylink\CurrentGroup'

```

in basic powershell returns `True`?

---

<div class="post-metadata">

### Author: ![mckownam](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mckownam](https://discourse.chef.io/u/mckownam)
#### Post date: [July 26, 2016, 2:38pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/5 "2016-07-26T14:38:22Z")

</div>

The path in powershell returns false; I am looking into what may be causing that since the path is easily found via regedit, so this is likely being caused by a permissions issue.

---

<div class="post-metadata">

### Author: ![mckownam](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mckownam](https://discourse.chef.io/u/mckownam)
#### Post date: [August 2, 2016, 12:32pm UTC](https://discourse.chef.io/t/registry-key-resource-dislikes-spaces/8973/6 "2016-08-02T12:32:45Z")

</div>

Okay, so the solution that I ended up using was to entirely remove all built-in chef registry\_key functions and just use powershell to find the key, pipe it to file, then read it into a variable in chef (note: the “Wow6432Node” part is removed for Server OS, present on desktop OS):

powershell\_script ‘FindRegKey’ do  
code \<\<-EOH  
$key = ‘HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC\SYLINK\SyLink’  
(Get-ItemProperty -Path $key).PreferredGroup | Out-File C:\#{foldername}\#{outfile} -Encoding "UTF8"  
EOH  
end  
regKey = ::File.read(“C:\#{foldername}\#{outfile}”)
