OK - I've done a bit of research and it seems that by using the regdelete
method you need to replace "\" with "\\" if the valuename has any
backslashes in it. However, for some odd reason, I can't seem to get it to
delete the following:

Key: HKLM\SOFTWARE\Microsoft\NAL\CLIENT\Preferred AbExprtDB\CAP List for
site KNA\
Value Name: MSWNET:["SMS_SITE=SITENAME"]\\\CAP_SITESERVER\
No Value Data

The error generated states invalid root - which tells me that it is hanging
up on the backslashes in the value name. Ok, that's fine, I figured if I
replaced the "\" with "\\", then it would solve my problem, but it still
didn't work after that, resulting in the same error.

Is there something I'm missing here?

Thanks all...!
Rob

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

strSMSSiteName = "SITENAME"
strCAPServer = "SITESERVER"
strComputer = "."

const HKEY_LOCAL_MACHINE = &H80000002

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\NAL\CLIENT\Preferred " _
& AbExprtDB\CAP List for site SITENAME"

oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
arrValueNames, arrValueTypes

For i=0 To UBound(arrValueNames)

If UCase(arrValueNames(i)) <> UCase("MSWNET:[" & Chr(34) _
& "SMS_SITE=strSMSSiteName" & Chr(34) & "]\\" & strCAPServer _
& "\cap_" & strSMSSiteName & "\") Then

strDeleteKey = arrValuenames(i)
'Here's where I tried strDeleteKey =
replace(arrValuenames(i),"\","\\") to no avail.

strDelete = "HKLM\" & strKeyPath & "\" & strDeleteKey

WshShell.RegDelete strDelete
End If
Next

Re: troubles deleting a regkey via regdelete by maximillianx

maximillianx
Wed Sep 14 11:27:26 CDT 2005

Sorry, should mention that the key name that I defined is actually correct
in my working script on my workstation...I changed some names to a generic
"SITENAME", but didn't replace all instances of "KNA" (our site name) in my
example below, so that's not the issue - in case you were wondering!

Rob

--

--------------------------------------------------------------------------------------------
WSUS Beginner Admin FAQ -->
http://uphold2001.brinkster.net/vbshf/wsus/wsus_faq.htm
--------------------------------------------------------------------------------------------
"maximillianx" <u1p2h3o4l5d2001@hotmail.com> wrote in message
news:uuFVphUuFHA.908@tk2msftngp13.phx.gbl...
> OK - I've done a bit of research and it seems that by using the regdelete
> method you need to replace "\" with "\\" if the valuename has any
> backslashes in it. However, for some odd reason, I can't seem to get it
> to delete the following:
>
> Key: HKLM\SOFTWARE\Microsoft\NAL\CLIENT\Preferred AbExprtDB\CAP List for
> site KNA\
> Value Name: MSWNET:["SMS_SITE=SITENAME"]\\\CAP_SITESERVER\
> No Value Data
>
> The error generated states invalid root - which tells me that it is
> hanging up on the backslashes in the value name. Ok, that's fine, I
> figured if I replaced the "\" with "\\", then it would solve my problem,
> but it still didn't work after that, resulting in the same error.
>
> Is there something I'm missing here?
>
> Thanks all...!
> Rob
>
> -------------------------------------------------
>
> strSMSSiteName = "SITENAME"
> strCAPServer = "SITESERVER"
> strComputer = "."
>
> const HKEY_LOCAL_MACHINE = &H80000002
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\Microsoft\NAL\CLIENT\Preferred " _
> & AbExprtDB\CAP List for site SITENAME"
>
> oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
> arrValueNames, arrValueTypes
>
> For i=0 To UBound(arrValueNames)
>
> If UCase(arrValueNames(i)) <> UCase("MSWNET:[" & Chr(34) _
> & "SMS_SITE=strSMSSiteName" & Chr(34) & "]\\" & strCAPServer _
> & "\cap_" & strSMSSiteName & "\") Then
>
> strDeleteKey = arrValuenames(i)
> 'Here's where I tried strDeleteKey =
> replace(arrValuenames(i),"\","\\") to no avail.
>
> strDelete = "HKLM\" & strKeyPath & "\" & strDeleteKey
>
> WshShell.RegDelete strDelete
> End If
> Next
>



Re: troubles deleting a regkey via regdelete by maximillianx

maximillianx
Wed Sep 14 11:50:18 CDT 2005

Well... I was able to work something out using WMI registry manipulation
here:

http://www.serverwatch.com/tutorials/article.php/1476861

Seems I have a little bit to learn about this method! It's quite effective
:)

Rob

--------------------------------------------------------------------------------------------
WSUS Beginner Admin FAQ -->
http://uphold2001.brinkster.net/vbshf/wsus/wsus_faq.htm
--------------------------------------------------------------------------------------------
"maximillianx" <u1p2h3o4l5d2001@hotmail.com> wrote in message
news:u9nWzkUuFHA.2948@TK2MSFTNGP15.phx.gbl...
> Sorry, should mention that the key name that I defined is actually correct
> in my working script on my workstation...I changed some names to a generic
> "SITENAME", but didn't replace all instances of "KNA" (our site name) in
> my example below, so that's not the issue - in case you were wondering!
>
> Rob
>
> --
>
> --------------------------------------------------------------------------------------------
> WSUS Beginner Admin FAQ -->
> http://uphold2001.brinkster.net/vbshf/wsus/wsus_faq.htm
> --------------------------------------------------------------------------------------------
> "maximillianx" <u1p2h3o4l5d2001@hotmail.com> wrote in message
> news:uuFVphUuFHA.908@tk2msftngp13.phx.gbl...
>> OK - I've done a bit of research and it seems that by using the regdelete
>> method you need to replace "\" with "\\" if the valuename has any
>> backslashes in it. However, for some odd reason, I can't seem to get it
>> to delete the following:
>>
>> Key: HKLM\SOFTWARE\Microsoft\NAL\CLIENT\Preferred AbExprtDB\CAP List for
>> site KNA\
>> Value Name: MSWNET:["SMS_SITE=SITENAME"]\\\CAP_SITESERVER\
>> No Value Data
>>
>> The error generated states invalid root - which tells me that it is
>> hanging up on the backslashes in the value name. Ok, that's fine, I
>> figured if I replaced the "\" with "\\", then it would solve my problem,
>> but it still didn't work after that, resulting in the same error.
>>
>> Is there something I'm missing here?
>>
>> Thanks all...!
>> Rob
>>
>> -------------------------------------------------
>>
>> strSMSSiteName = "SITENAME"
>> strCAPServer = "SITESERVER"
>> strComputer = "."
>>
>> const HKEY_LOCAL_MACHINE = &H80000002
>>
>> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
>> strComputer & "\root\default:StdRegProv")
>>
>> strKeyPath = "SOFTWARE\Microsoft\NAL\CLIENT\Preferred " _
>> & AbExprtDB\CAP List for site SITENAME"
>>
>> oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
>> arrValueNames, arrValueTypes
>>
>> For i=0 To UBound(arrValueNames)
>>
>> If UCase(arrValueNames(i)) <> UCase("MSWNET:[" & Chr(34) _
>> & "SMS_SITE=strSMSSiteName" & Chr(34) & "]\\" & strCAPServer _
>> & "\cap_" & strSMSSiteName & "\") Then
>>
>> strDeleteKey = arrValuenames(i)
>> 'Here's where I tried strDeleteKey =
>> replace(arrValuenames(i),"\","\\") to no avail.
>>
>> strDelete = "HKLM\" & strKeyPath & "\" & strDeleteKey
>>
>> WshShell.RegDelete strDelete
>> End If
>> Next
>>
>
>