+ Reply to Thread
Results 1 to 12 of 12

Help writing to registry using slashes "\"

  1. #1
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Help writing to registry using slashes "\"

    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

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    You can't do it with RegWrite and Shell. You need to use an alternative method, such as API calls or WMI.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: Help writing to registry using slashes "\"

    I was afraid of that.

    Question, do you happen to have any references or examples that I can look at? I looked up WMI and it looks like VBScript. I know from working with it in the past the VBS needs to be very precise.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    Not sure what I was thinking of earlier - you cannot actually use a backslash in a key name. Windows will not allow it.

  5. #5
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: Help writing to registry using slashes "\"

    I know it is possible because Office does it when you activate add-ins. Please see the directory of:

    Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\[version ##]\Excel\Add-in Manager

    Attachment 742034

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    Your attachment doesn't work for me. Are you sure you're talking about a key (the things that look like folders), not a value?

  7. #7
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: Help writing to registry using slashes "\"

    Yes. The name is "C:/Something/Something" I will upload it on another server.

    https://drive.google.com/file/d/1guC...ew?usp=sharing

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    The key in that image is Add-in manager. The items in the right hand pane are values.

  9. #9
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: Help writing to registry using slashes "\"

    Then how would I go about making entries like that? Every time I try I make more directories instead of the values.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    Here's a simple example using API:

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor frabulator's Avatar
    Join Date
    09-16-2015
    Location
    United States
    MS-Off Ver
    2019
    Posts
    101

    Re: Help writing to registry using slashes "\"

    That works perfectly! Thank you so much!

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Help writing to registry using slashes "\"

    Glad to help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 11-19-2020, 08:30 PM
  2. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  3. Replies: 2
    Last Post: 07-24-2017, 02:19 AM
  4. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. Replies: 1
    Last Post: 09-12-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1