See the question and my original answer on StackOverflow

The .reg file as displayed here is invalid, the \ character in COM server's path must be escaped, so it should be something like this instead:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{0DF1F277-A2CD-4202-86AA-4C0BF1B8C5E4}\InProcServer32]
@="C:\\Users\\Username\\OneDrive\\Desktop\\COM\\COMIExecuteCommand.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\txtfile\shell\printnamestodebugger]
@="Print names to debugger"
[HKEY_CLASSES_ROOT\txtfile\shell\printnamestodebugger\command]
"DelegateExecute"="{0DF1F277-A2CD-4202-86AA-4C0BF1B8C5E4}"

As a side note, when running on Windows 11, the association path using the txtfile key will probably won't work as is, but this could be used instead (in the case of .txt files only):

HKEY_CLASSES_ROOT\SystemFileAssociations\text\shell\printnamestodebugger