Remove registry Key vbs/gpo

Hi
Trying to remove a registry key from a Windows 7 Pro PC either through vbs or GPO. The problem is that the key value is unique on each PC.

So
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Provider Filters\{2C1C77B1-D33E-4C4D-B644-5DCD6A9E5690}]
@="2XCredentialProviderFilter"

2XCredentialProviderFilter is always present in that key, but the key name itself is random and I want to delete the key  based on the fact that it has a string called 2XCredentialProviderFilter

Does anyone know if/how this can be achieved?

thanks
kwatt562Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
This can only be done on startup via GPO.
Or you can use psexec to remotely execute the vbscript.

Here is an example of vbscript search through registry.
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/bef4b845-ef77-4882-afe1-a479c4531b03/vbscript-to-find-software-in-the-registry-and-then-run-the-uninstall-string?forum=ITCG

Test locally first without any removal to make sure it will do what you want.

If I needed to implement this, I would do it in two stages. One have the script run and report on which system has this string value in which registry key.

Then change the mode to delete the key.
0
kwatt562Author Commented:
Isn't that to uninstall a program? I am only trying to delete the above mentioned keys, thanks
0
arnoldCommented:
The example includes a search within the registry which is what you need.  You would alter the starting point to the hkey_local_machine you referenced in your question.
0
RobSampsonCommented:
Hi, if you run this script as a StartUp script, under Computer Configuration, it will look for the 2XCredentialProviderFilter value in all of the keys under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Provider Filters and then delete the relevant key.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
strKey = "Software\Microsoft\Windows\CurrentVersion\Authentication\Credential Provider Filters\"
strComputer = "."
strFind = "2XCredentialProviderFilter"

If Right(strKey, 1) = "\" Then strKey = Left(strKey, Len(strKey) - 1)
Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\default:StdRegProv")
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
If Not IsNull(arrSubKeys) Then
	For Each strSubKey In arrSubKeys
		strValueName = strKey & "\" & strSubKey & "\"
		objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strValueName, "", strValueData
		If strValueData = strFind Then
			WScript.Echo "Deleting " & strValueName & " because it has a value of " & strValueData
			On Error Resume Next
			intReturn = objRegistry.DeleteKey(HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey)
			If intReturn = 0 And Err.Number = 0 Then    
				Wscript.Echo strSubKey & " successfully deleted"
			Else
			    Wscript.Echo "Error deleting " & strSubKey & ". Return code = " & intReturn & ", error = " & Err.Number & ": " & Err.Description
			End If
			Err.Clear
			On Error GoTo 0
		End If
	Next
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobSampsonCommented:
It has WScript.Echo statements that you may want to remove when you put it into production.

Regards,

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.