Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set empty default registry key value using regwrite ?

427 views
Skip to first unread message

Vilius Mock�nas

unread,
Jun 11, 2009, 5:06:22 AM6/11/09
to
Hello,

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
like "(value not set)" in regedit).

How do I set default key value to emty value using RegWrite ?

thanks
Vilius


T Lavedas

unread,
Jun 11, 2009, 9:08:09 AM6/11/09
to

The only workaround I know is to write a key one level lower than the
desired level and delete it, something like this ...

sKey = "HKCU\SOFTWARE\somekey\dummy\"
with CreateObject("WScript.Shell")
.RegWrite sKey, Empty
.RegDelete sKey
end with
wsh.echo "Done"

I suppose there might be a way using the WMI registry class, but it's
bound to be more complicated than this little trick.

Tom Lavedas
***********

Pegasus [MVP]

unread,
Jun 11, 2009, 9:27:06 AM6/11/09
to
Check the replies you received in the scripting.vbscript newsgroup, then
have a look at this link to see why crossposting is fine but multiposting
isn't: http://www.blakjak.demon.co.uk/mul_crss.htm


"Vilius Mock�nas" <v_moc...@yahoo.com> wrote in message
news:%23k7cdPn...@TK2MSFTNGP02.phx.gbl...

0 new messages