I want to delete a registry value that has a path in it, like the following:

c:\test\test2

If I try the following:

Dim WshShell
WshShell.RegDelete "HKLM\Software\Script Test\Key1\c:\test\test2"

I get the following error: Unable to remove registry key
"HKLM\Software\Script Test\Key1\c:\test\test2". I think this probably
because it is seeing the c:\test\test2 as registry keys and not a value. Is
there anything else I can do? I do not want to delete the entire registry
key.

Thanks and Merry Christmas.
Mark

Re: Deleting registry value with path by Dave

Dave
Wed Dec 24 10:53:26 CST 2003

What is the name of the Reg_Sz string value? Delete the value by name not by
contents. Else if you want to keep the Reg_Sz string value but empty the
string then use RegWrite method to write "" into it.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]
http://www.microsoft.com/protect.

"Mark" wrote:
| I want to delete a registry value that has a path in it, like the
following:
|
| c:\test\test2
|
| If I try the following:
|
| Dim WshShell
| WshShell.RegDelete "HKLM\Software\Script Test\Key1\c:\test\test2"
|
| I get the following error: Unable to remove registry key
| "HKLM\Software\Script Test\Key1\c:\test\test2". I think this probably
| because it is seeing the c:\test\test2 as registry keys and not a value.
Is
| there anything else I can do? I do not want to delete the entire registry
| key.
|
| Thanks and Merry Christmas.
| Mark
|
|



Re: Deleting registry value with path by Richard

Richard
Wed Dec 24 11:03:10 CST 2003

Mark wrote:

> I want to delete a registry value that has a path in it, like the
following:
>
> c:\test\test2
>
> If I try the following:
>
> Dim WshShell
> WshShell.RegDelete "HKLM\Software\Script Test\Key1\c:\test\test2"
>
> I get the following error: Unable to remove registry key
> "HKLM\Software\Script Test\Key1\c:\test\test2". I think this probably
> because it is seeing the c:\test\test2 as registry keys and not a value.
Is
> there anything else I can do? I do not want to delete the entire registry
> key.

Hi,

You are correct. This is a known flaw in all of the WshShell registry
methods. You can either use WMI or use the WshShell object's Run method to
run regedit and merge a *.reg file that deletes the key. See this newsgroup
message for examples:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3E67A654.F6CF4AB6%40hydro.com

The regedit example deletes a key. To delete a value I believe the reg file
would be:

REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Test]
"c:\test\test2"=-

Be sure the file ends with a carriage return.

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--




Re: Deleting registry value with path by Mark

Mark
Wed Dec 24 11:15:04 CST 2003

I should have made that more clear the "c:\test\test2" is the name of the
value I want to delete, I don't care what data it has in it.

Mark
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:u#tG05jyDHA.3436@tk2msftngp13.phx.gbl...
> What is the name of the Reg_Sz string value? Delete the value by name not
by
> contents. Else if you want to keep the Reg_Sz string value but empty the
> string then use RegWrite method to write "" into it.
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
> http://www.microsoft.com/protect.
>
> "Mark" wrote:
> | I want to delete a registry value that has a path in it, like the
> following:
> |
> | c:\test\test2
> |
> | If I try the following:
> |
> | Dim WshShell
> | WshShell.RegDelete "HKLM\Software\Script Test\Key1\c:\test\test2"
> |
> | I get the following error: Unable to remove registry key
> | "HKLM\Software\Script Test\Key1\c:\test\test2". I think this probably
> | because it is seeing the c:\test\test2 as registry keys and not a value.
> Is
> | there anything else I can do? I do not want to delete the entire
registry
> | key.
> |
> | Thanks and Merry Christmas.
> | Mark
> |
> |
>
>



Re: Deleting registry value with path by Dave

Dave
Wed Dec 24 11:32:11 CST 2003

Then you may want to follow Richard's suggestion. Seems not very good
practice to name a key with \ / * : ? " < > | control characters.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]
http://www.microsoft.com/protect.

"Mark" wrote:
| I should have made that more clear the "c:\test\test2" is the name of the
| value I want to delete, I don't care what data it has in it.