I need to write to the registry and make a reg key with the name of a location directory. Note, this has to be the name of the key, not the value/data of the key.

I am using the method below, which works for keys without the backslash in its name. When the name is something like this:

RegDir = "HKEY_CURRENT_USER\SOFTWARE\Something"
RegKey = "C:\Some Folder\Some File\"

instead of creating a key of "C:\Some Folder\Some File\" inside of "HKEY_CURRENT_USER\SOFTWARE\Something", I end up creating a key inside of the directory of "HKEY_CURRENT_USER\SOFTWARE\Something\C:\Some Folder\Some File\".

I have tried escaping the backslash (C:\\Some Folder\\Some File\\) and replacing it with the chr(92), but neither work.

Any insight would be great.

Thanks in advance.

~Frab

Sub RegKeySave(i_RegKey As String, _
               i_Value As String, _
      Optional i_Type As String = "REG_DWORD")
Dim myWS As Object

  'access Windows scripting
  Set myWS = CreateObject("WScript.Shell")
  'write registry key
  myWS.RegWrite i_RegKey & i_Value, i_Value, i_Type
  

End Sub