none
Trying to add a value to REG_NONE in the Registry RRS feed

  • Question

  • I'm trying to add a value to the Windows Registry with key type of REG_NONE. I looked here, among other places, and it was no help: http://superuser.com/questions/331811/how-to-create-registry-key-of-type-reg-none

    Here's the command I am using:

    reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v IconUnderline /t REG_NONE /d 3
    

    When that command executes, the data it sets is 33 00 00 00.

    HOWEVER, it needs to be 03 00 00 00!

    How can I modify the command to get it to add 03 00 00 00 and NOT 33 00 00 00?

    Thanks!

    Tuesday, September 16, 2014 2:49 PM

Answers

  • You can't do it with REG ADD.  The interface is only character and the reg none is bytes.  Microsoft has not chosen to enable this.

    You can use  a .reg file"

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
    "IconUnderline"=hex(0):03,00,00,00
    

    No other way short of the API calls.


    ¯\_(ツ)_/¯

    • Marked as answer by mgoblue0970 Tuesday, September 23, 2014 2:40 PM
    Tuesday, September 16, 2014 3:17 PM

All replies

  • What is your goal (not the attempted steps)?

    -- Bill Stewart [Bill_Stewart]

    Tuesday, September 16, 2014 2:51 PM
    Moderator
  • You can't do it with REG ADD.  The interface is only character and the reg none is bytes.  Microsoft has not chosen to enable this.

    You can use  a .reg file"

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
    "IconUnderline"=hex(0):03,00,00,00
    

    No other way short of the API calls.


    ¯\_(ツ)_/¯

    • Marked as answer by mgoblue0970 Tuesday, September 23, 2014 2:40 PM
    Tuesday, September 16, 2014 3:17 PM
  • According to my docs it is a DWORD and not a REG_NONE value.  Microsoft has removed reg none from most areas.  It still shows only in Windows XP.

    This will do what you are asking for:
    reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v IconUnderline /t REG_DWORD /d 3

    I believe that REG_NONE is a leftover from Windows 95.


    ¯\_(ツ)_/¯

    Tuesday, September 16, 2014 3:21 PM
  • What's the goal/purpose of setting that registry value? (What is it you're trying to accomplish?)

    -- Bill Stewart [Bill_Stewart]

    Tuesday, September 16, 2014 3:22 PM
    Moderator
  • It's clearly displayed as REG_NONE in the Registry... I marked your Tuesday, September 16, 2014 3:17 PM post as the answer though.  Thanks!
    Tuesday, September 23, 2014 2:41 PM
  • It's clearly displayed as REG_NONE in the Registry... I marked your Tuesday, September 16, 2014 3:17 PM post as the answer though.  Thanks!

    I agree with jrv that this appears to be a DWORD in Windows 7 and higher (probably Vista, too, but I can't check that). If you really want to try to make it a NONE value, though, you can do it with PowerShell:

    Method 1: reg.exe

    reg.exe add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v IconUnderline /t REG_NONE /d ([char] 3)


    Method 2: New-ItemProperty cmdlet

    $Params = @{
        Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer"
        Name = "IconUnderline"
        PropertyType = "None"   # Microsoft.Win32.RegistryValueKind
        Value = [System.BitConverter]::GetBytes(3)
    }

    New-ItemProperty @Params # Add -Force to command if the value may already exist


    I'm not sure if you can do method 1 from a batch file or not, but you should be able to convert it to a VBScript command if you can't use PowerShell. The trick is sending the ASCII character that corresponds to the value you're after (3), which is an unprintable character in this case.


    • Edited by Rohn Edwards Tuesday, September 23, 2014 8:56 PM
    Tuesday, September 23, 2014 8:55 PM
  • Error in the original code is, that the byte array is not empty which is passed to the command.

    In case someone comes looking for the right answer through Google, this is the correct way to do it:

    $Params = @{
    Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer"
    Name = "IconUnderline"
    PropertyType = "None"   # Microsoft.Win32.RegistryValueKind
    Value = New-Object Byte[] 0
    }

    New-ItemProperty @Params

    The above code sets the value to (zero-length binary value). If you need anything else into it, then just fix the byte array to the value you need to.
    • Proposed as answer by Ongelmanratkoja Thursday, February 16, 2017 10:50 AM
    • Edited by Ongelmanratkoja Thursday, February 16, 2017 10:53 AM additional explanation
    Thursday, February 16, 2017 10:49 AM
  • Try this:

    $x=[byte[]]::new(4)
    New-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name IconUnderline -type None -Value  $x


    \_(ツ)_/

    Thursday, February 16, 2017 11:07 AM
  • A byte array of zero length won't work

    New-Object Byte[] 4

    will work.


    \_(ツ)_/

    Thursday, February 16, 2017 11:09 AM
  • @All you can do it via powershell.

    $hex = ("0x03 0x00 0x00 0x00").split(" ")
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer-Name "IconUnderline" -Type UNKNOWN -Value ([byte[]]$hex) -force

    • Proposed as answer by Mathias Rühn Tuesday, January 28, 2020 8:33 AM
    Tuesday, January 28, 2020 8:33 AM