Jump to content

How can I remove Reg keys throgh command script?


 Share

Recommended Posts

OK, so what I want to do is prevent people from having the choice to RIP a CD when Autoplay pops up after inserting a CD.

The Branch is located at:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival]

And the keys I want to get rid of are:

MSRipCDAudioOnArrival

NeroAutoPlay2RipCD

NeroAutoPlay2AudioToNeroDigital

And then within the Branch:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers]

I want to get rid of the corresponding "subbranches" and the keys within

EX: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\MSRipCDAudioOnArrival\

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\NeroAutoPlay2RipCD

and of course I want to get rid of Any/All iTunes keys as well.

Is there a simple way i can accomplish this with command line scripting (batch script)?

Link to comment
Share on other sites


REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\MSRipCDAudioOnArrival\" /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\NeroAutoPlay2RipCD" /f

Link to comment
Share on other sites

Thanks, I worte the script and got it to work with a little tweaking. I had to use the /v ValueName for some of them like below:

 REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v NeroAutoPlay2RipCD /f

Now the other tricky thing, Is there a way to silently run a script on startup that will check for the presence of a particular key or keys and if present, delete them?

This is so if the user installs iTunes, certain reg keys will be present and only if those are present, will be deleted.

Like this key for example: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesImportSongsOnArrival

Link to comment
Share on other sites

OK, I think I figured it out unless someone knows a better way. The only thing I'm concerned about is the use of CMDOW because the Antivirus programs usually kill this file and then the script won't run correctly. But here's the rough:

cmdow @ /HID
@ECHO OFF

ping -n 2 localhost> NUL
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesImportSongsOnArrival
if "%errorlevel%" GTR "0" (goto fail) ELSE goto pass1

:fail
echo Key not found
exit

:pass1
echo 1st Key is present
ping -n 2 localhost> NUL
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesPlaySongsOnArrival
if "%errorlevel%" GTR "0" (goto fail) ELSE goto pass2

:pass2
echo 2nd Key is present
ping -n 2 localhost> NUL
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesShowSongsOnArrival
if "%errorlevel%" GTR "0" (goto fail) ELSE goto pass3

:pass3
echo 3rd Key is present
ping -n 2 localhost> NUL
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesBurnCDOnArrival
if "%errorlevel%" GTR "0" (goto fail) ELSE goto pass4

:pass4
ping -n 2 localhost> NUL
Echo Machine tests positive for iTunes
Echo Now Going to kill the keys!
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesBurnCDOnArrival" /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesImportSongsOnArrival" /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesPlaySongsOnArrival" /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\iTunesShowSongsOnArrival" /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesShowSongsOnArrival /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesPlaySongsOnArrival /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesImportSongsOnArrival /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\PlayCDAudioOnArrival" /v iTunesBurnCDOnArrival /f
Echo Completed!
ping -n 4 localhost> NUL
EXIT

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...