OK, I did a search and found something similar but wasn't able to get it to do exactly what I wanted.
The Area of registry I'm looking at is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival
and the Values I'm looking for are:
iTunesPlaySongsOnArrival
iTunesShowSongsOnArrival
iTunesBurnCDOnArrival
iTunesImportSongsOnArrival

If and ONLY If any of them are present, I would like to delete them (the values or whatever you call them), but leave everything else normally found in the 'PlayCDAudioOnArrival' key

Also, there are subkeys in:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\
such as: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesImportSongsOnArrival
that I would like to also detect and get rid of the whole subkey (iTunesImportSongsOnArrival)

I tried this code, but it deletes the whole 'PlayCDAudioOnArrival" key. I also want to run the script silently without any popups.
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival"
strValueName = "MSRipCDAudioOnArrival"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
Wscript.Echo "The registry key does not exist."
Else
Wscript.Echo "The registry key exists."
objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

End If
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
you prolly wanna use the removeregistry table instead of a script if this is an msi installation.
Answered 02/26/2009 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
I'm not sure about a table, I just want to remove those particular registry keys/values, not the program..
Answered 02/26/2009 by: Thinkster
Yellow Belt

Please log in to comment
0
I tried this code, but it deletes the whole 'PlayCDAudioOnArrival" key.Well, it will do if you use the WMI registry provider object's 'DeleteKey' method! :) You want 'DeleteValue'. My advice would be to get hold of the cRegistry.VBS script from, IIRC, http://www.jsware.net. It's a neat encapsulation of the WMI registry provider object, with easy to use functions. It takes away a great deal of the pain associated with using this object. Plus, in contrast with 99% of code - particularly script - on the web, its code is an exercise in neat, concise and "it does exactly what it says on the tin" programming.

I also want to run the script silently without any popups.Either remove the WScript.Echo statements or, better, replace them with a call to a log file-writing function (of which there are a gazillion examples on the web). You might also write to the Event Log instead/as well.
Answered 02/27/2009 by: VBScab
Red Belt

Please log in to comment
0
Dude, did I say anything about removing a program?

Sigh.....

google removeregistry table site:microsoft.com

Anyway, if it's not part of a package, there are PLENTY of sample scripts to delete keys and subkeys and values (and suppress errors if they don't exist)

Sigh....

google scripting guys delete registry key and subkeys site:microsoft.com
Answered 02/27/2009 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
Answer this question or Comment on this question for clarity