# Unable to create a Windows registry 'folder'

**URL:** <https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893>\
**Category:** Questions & Answers\
**Created:** [April 26, 2023, 7:58am UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893 "2023-04-26T07:58:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dexter](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dexter/32/1432_2.png) [@Dexter](https://racket.discourse.group/u/Dexter)\
**Post date:** [April 26, 2023, 7:58am UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893/1 "2023-04-26T07:58:57Z")

</div>

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)  
etc...  
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)](https://developer.shotgridsoftware.com/af0c94ce/)

Any clue?

Thanks!

Dexter

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [April 26, 2023, 3:17pm UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893/2 "2023-04-26T15:17:18Z")

</div>

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:

```scheme
(write-resource "HKEY_CURRENT_USER"
                "SOFTWARE\\Joel\\abc\\test"
                "hello2"
                #:create-key? #t)

```

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [April 26, 2023, 4:50pm UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893/3 "2023-04-26T16:50:30Z")

</div>

> [@joeld](#):
>
> It may have something to do with permissions

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

```scheme
  (write-resource "HKEY_CLASSES_ROOT"
                  ".Joel\\abc\\test"
                  "hello2"
                  #:create-key? #t))

```

This is on Win 10 Pro 22H2.

---

<div class="post-metadata">

**Author:** ![Dexter](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dexter/32/1432_2.png) [@Dexter](https://racket.discourse.group/u/Dexter)\
**Post date:** [April 26, 2023, 5:34pm UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893/4 "2023-04-26T17:34:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [April 26, 2023, 10:23pm UTC](https://racket.discourse.group/t/unable-to-create-a-windows-registry-folder/1893/5 "2023-04-26T22:23:51Z")

</div>

I feel like the docs for `write-resource` are a bit misleading, so I made [a PR](https://github.com/racket/racket/pull/4641) to update them.
