There doesn't seem to be a way to just create
a key. You can just use:
obj1.RegWrite "HKCU\Software\somekey\", ""
It sets "" instead of [value not set], but so what?
That's the same thing in practice. If you even just
click "modify" in the context menu for a new key, the
default value will be set to "". Either way, RegRead
will return "". It's just a quirk.
(Also, the default value is string type by definition.
You're treating it as DWORD even though you
specified REG_SZ.)
The help is kind of strange for RegWrite. It says
the 2nd parameter is:
"The name of the new key you want to create, the name of the value you want
to add to an existing key, or the new value you want to assign to an
existing value-name."
I don't know of any way to name the new key with
the 2nd parameter. I also don't know of any way to
name the new value that way. The 2nd parameter is
the value data.
(To add to the confusion, the help even gets the
terminology wrong. Generally it's known as key, value
and data, whereas the scripting help refers to
"value-name" for value and "value" for data.)
Quote:
>
> RegWrite vbscript function is a bit tricky to me. For example I want to
> create registry key:
>
> dim obj1
> set obj1 = CreateObject( "WScript.Shell" )
> obj1.RegWrite( "HKCU\Software\somekey\", 1, "REG_SZ" )
>
> So OK example above creates somekey key with default value 1, but my goal
> here is to set default value to empty value, not 1. (emty value is
displayed
Quote:
> like "(value not set)" in regedit).
>
> How do I set default key value to emty value using RegWrite ?
>
> thanks
> Vilius
>
>