none
[SOLVED] Highest value for regwrite REG_DWORD RRS feed

  • Question

  • Hi everybody,

    I'm writing some script used by our MDT (but it doesn't matter), and I need to write REG_DWORD registry value in a wsf script.

    I'm doing my test in VBS files on my own PC and for some keys I write :

    c.RegWrite "HKLM\SOFTWARE\JavaSoft\Java Update\Policy\EnableJavaUpdate", 0, "REG_DWORD"

    and there's no problem.

    But when I want to write :

    c.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents", ffffffff, "REG_DWORD"

    That does not work.

    I understood that I didn't have to write in hex code but in decimal :
    so I converted ffffffff into 4294967295

    -> That does not work to (without error code or anything else) -> the key's value is not change

    I've tried many decimal values and found that the highest I can put is : 2139999999 ?????? (what's this number?)

    How can I do to write a registry key value using the regwrite function in REG_DWORD type with 0xffffffff ?

    Thank you for your help


    Tuesday, April 14, 2015 10:08 AM

Answers

  • You code that doesn't work is wrong for vbs.

    It should be &hffffffff if it's hex. (and in C it's 0xffffffff). &h or 0x say the number is hex.

    Most programming languages use signed integers not unsigned.

    They write whatever you want to a variable, but reading it it is interpreted (ie if you print it) as signed. 0xffffffff is -1 signed.


    David Candy

    • Marked as answer by Thorongil 19 Thursday, April 23, 2015 1:32 PM
    Wednesday, April 15, 2015 9:08 AM
  • FOUND IT!!!!

    It didn't appear to be clear because 2139999999 is not the half of 4294967295, but by testing some negative values :
    It works!

    So, to have a REG_DWORD with ffffffff value you have to write:

    c.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents", -1, "REG_DWORD"

    But if there's someone to explain why 2139999999 is the maximum postive and what is the minimum negative...
    I'll take it ;-)
    • Marked as answer by Thorongil 19 Wednesday, April 15, 2015 7:18 AM
    Tuesday, April 14, 2015 4:22 PM

All replies

  • FOUND IT!!!!

    It didn't appear to be clear because 2139999999 is not the half of 4294967295, but by testing some negative values :
    It works!

    So, to have a REG_DWORD with ffffffff value you have to write:

    c.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents", -1, "REG_DWORD"

    But if there's someone to explain why 2139999999 is the maximum postive and what is the minimum negative...
    I'll take it ;-)
    • Marked as answer by Thorongil 19 Wednesday, April 15, 2015 7:18 AM
    Tuesday, April 14, 2015 4:22 PM
  • You code that doesn't work is wrong for vbs.

    It should be &hffffffff if it's hex. (and in C it's 0xffffffff). &h or 0x say the number is hex.

    Most programming languages use signed integers not unsigned.

    They write whatever you want to a variable, but reading it it is interpreted (ie if you print it) as signed. 0xffffffff is -1 signed.


    David Candy

    • Marked as answer by Thorongil 19 Thursday, April 23, 2015 1:32 PM
    Wednesday, April 15, 2015 9:08 AM
  • Hi,

    Thank you very much.

    But I didn't find anywhere this syntax for VBS : "&h"

    And I would prefer to use this one than the signed solution.

    Thursday, April 23, 2015 1:32 PM
  •  
    3.3.2 Number Tokens

    INTEGER = integer-literal ["%" / "&" / "^"]

    integer-literal = decimal-literal / octal-literal / hex-literal

    decimal-literal = 1*decimal-digit

    octal-literal = "&" [%x004F / %x006F] 1*octal-digit ; & or &o or &O

    hex-literal = "&" (%x0048 / %x0068) 1*hex-digit ; &h or &H

    octal-digit = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"

    decimal-digit = octal-digit / "8" / "9"

    hex-digit = decimal-digit / %x0041-0046 / %x0061-0066 ;A-F / a-f

    Static Semantics


    The <decimal-digit>, <octal-digit>, and <hex-digit> sequences are interpreted as unsigned integer values represented respectively in decimal, octal, and hexadecimal notation.


    Each <INTEGER> has an associated constant data value (section 2.1). The data value, value type (section 2.1) and declared type (section 2.2) of the constant is defined by the following table (if the Valid column shows No, this <INTEGER> is invalid):


    --------------------------------------------------------------------------------

    David Candy

    • Edited by DavidMCandy Friday, April 24, 2015 12:23 AM
    Friday, April 24, 2015 12:22 AM