Unable to create a Windows registry 'folder'

I tried every possible combination of params to write-resource to no avail. All I want to do is create a folder in HKEY_CLASSES_ROOT, and write entries into it.

I tried:

(write-resource "HKEY_CLASSES_ROOT\\MyFolder"
"." ""
#:create-key? #t)
-> writes a mred.ini file.

(write-resource "HKEY_CLASSES_ROOT"
"\\MyFolder" ""
#:create-key? #t)
I tried with and without #:type. Either I get the mred.ini file in home, or I get an entry directly in HKEY_CLASSES_ROOT, but never a folder with any entry in it.

I'm trying to write entries similar to this post:
Launching Applications Using Custom Browser Protocols - SG Developer (shotgridsoftware.com)

Any clue?



1 Like

It may have something to do with permissions on HKEY_CLASSES_ROOT. Like you, I was unable to get write-resource to create any subkeys (the term for registry “folders”) in that section.

However, it worked as expected when using a different section:

(write-resource "HKEY_CURRENT_USER"
                #:create-key? #t)
1 Like

Confirming this theory: when I ran DrRacket “as Administrator”, then I was able to create subkeys under HKEY_CLASSES_ROOT like so:

  (write-resource "HKEY_CLASSES_ROOT"
                  #:create-key? #t))

This is on Win 10 Pro 22H2.

1 Like

Oh that was as simple as that! Thanks a bunch!

I feel like the docs for write-resource are a bit misleading, so I made a PR to update them.