View Full Version : Automatically delete Registry values
06-14-1999, 11:58 AM
Somebody knows how to delete registry values automatically? (same values, several times for example at startup)
06-16-1999, 06:10 PM
Sure, but you need to create an .inf file rather than a .reg file, because .reg files merge the data into the registry so there's no way to delete a key, only to change it. If that's all you need to do, then simply include a command "regedit /s [path]filename.reg" in a batch file or from the run command and the .reg file will be merged (the /s parameter minimizes the process).
If you need to delete a key, then use an .inf file. They're plain old text files, but you definitely should read up on syntax, etc.
06-16-1999, 06:50 PM
I too am interested in deleting keys from the registry and would be grateful if you can provide any syntax examples of the commands to use in an inf file, in order to delete a key. Thanks.
06-17-1999, 12:09 AM
Yeah. I fiddled with them a while ago and tested this little .inf file...
Cut/paste the text between the "------------------------------" to a text file, and save it as filename.inf
Without going into a long discourse, you need every line of text.
[DefaultInstall] is where you define what operations you want to do.
DelReg=JMS.Del.Reg tells the computer you want to delete a registry key that you called JMS.Del.Reg
[JMS.Del.Reg] is where you define what that registry key will be. In this example, the key is HKEY_LOCAL_MACHINE\Software\JMS
I suggest that you make a backup of the registry and then create that JMS key under HKEY_LOCAL_MACHINE\Software, then install the .inf file and confirm that it does what you want it to do (if you leave the registry open while installing the inf file, click on the registry and refresh using F5). It should work--I just tested my system--so good luck!
07-04-1999, 07:08 PM
Any idea how to call the .inf file from the command line? I am trying to delete some keys across my LAN via a batch file called from the login script. Any help would be great!
07-05-1999, 05:22 PM
To create an .inf file to automatically delete registry entries, use any text editor (such as Notepad) to create the sample Del-reg.inf file shown below (between asterisked lines). Note that Del-reg.inf is not a required name, but it is used in these instructions.
; This file called Del-Reg.INF deletes the registry entries listed
; under the [RegChange] section. In this example it deletes the
; UserName value name under the key HKLM\network\Logon
; DelReg = RegChange
The line below the [DefaultInstall] section is remarked out with a semicolon to prevent someone from accidentally running the .inf file. If you want the option to run the .inf file without using Rundll, you should remove the semicolon.
RunIt is an arbitrary section name in the .inf file that should be executed.
The value following RunIt has the following meanings:
0 - Informs Windows 95 that a reboot is not necessary.
1 - Always silent reboot
2 - Always prompt reboot
Below the [RegChange] section is a value called username and a value called keyname to be deleted. These are sample entries and should be modified to list the registry entries that you want to be removed.
The entry in the [RegChange] section lists the registry entry or entries that you want to remove. Below are some guidelines for the proper syntax:
root-key, sub-key, [value name]
The value name is optional and is denoted by the  brackets. The comma place holder shown above must be included in this line. Please note that if the sub-key or Value name contains spaces you need to use quotes. Registry entries between quotes may be case sensitive. For example: HKLM,SOFTWARE\"XYZ inc"\settings,,
The root-key is represented by one of the following abbreviations:
HKCR is short for HKEY_CLASSES_ROOT
HKCU is short for HKEY_CURRENT_USER
HKLM is short for HKEY_LOCAL_MACHINE
HKU is short for HKEY_USERS
The sub-key is the continuation of the path to the value to be changed, for example:
HKLM,SOFTWARE\Microsoft\Windows\currentVersion\Fon ts removes the Fonts Key and all of its contents.
The value name entry allows the definition of a particular entry to be removed from a sub-key.
To run this sample file automatically when you log on to your computer, type the following line in the login script:
RunDLL setupx.dll,InstallHinfSection RunIt 0 path\Del-Reg.inf
where path is the location of the Del-reg.inf file. You can use a physical drive letter from your local computer and a path, or a Universal Naming Convention (UNC) path like \\server\sharename.
07-06-1999, 04:09 PM
I've been following this thread with great interest.
I don't mean to interrupt, but how would you do this on an NT box with the users locked out of the registry. And not only the deleting of a key but the creating of a key also.
07-06-1999, 10:20 PM
First of all, NT requires a different "Signature=" value--I'd suggest browsing any .inf files on your NT machine to see what that value is. Otherwise, I'm pretty sure (but not certain) that inf files work pretty much the same regardless if you're running 9x or NT.
So, to add a key use the AddReg function, rather than the DelReg function. There's a lot more to adding keys because you can also add values within (or under, or whatever) the keys. The format is kinda tricky, and I wish I had some examples for you.
You may wanna try going to http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/winresource/dnwin95/s734b.htm Go ahead and register (its free) and you'll find a wealth of information there. I find it's hard to navigate, so where yoy wanna go after registering is to Windows 96 Resource Guide Appendix C.
If you want to delete the key and all the values in the key, you can use the regedit /d regpath command in a batch file or login script.
i.e. regedit /D HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\testkey
07-16-1999, 03:35 AM
hmm... well, I got all excited because I thought here's an undocumented switch, so I tried it... no go.
Mort, I did exactly as you suggested and ran regedit at the command line with and without quotes around the reg key. Regedit kept looking for a .reg file to import.
Lemme know if I'm wrong, but until then, I stand by my previous posts: You can't delete a key or value using regedit... you can CHANGE a value, but not delete it...
if you boot in msdos mode and type regedit, it should display some of the flags. One is the /D. I have tested it, the only thing is that it will completely delete the specified key, not just the data in it. I added a blank key to HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies. Upon rebooting in dos mode and running the /D on that key it was no longer there when I booted into windows. You may want to search Microsofts Knowlege Base to see if they offer any more input.
07-16-1999, 04:52 PM
How curious. Typing "regedit" while in DOS mode does bring up a list of command line parameters including:
where regpath2 is the registry path to be deleted.
So, I booted into Win98, went into the registry and created the following key:
I closed regedit, opened a DOS window and entered:
regedit /D HKEY_LOCAL_MACHINE\Software\Stolz\WizBang
I got a dialog box saying "Are you sure you want to import the contents of HKEY_LOCAL_MACHINE\Software\Stolz\WizBang into the registry?"
Note it said "import" and seems to consider the regpath2 parameter to be a file. Anyway, I say yes and get the following (or similar message):
Could not import HKEY_LOCAL_MACHINE\Software\Stolz\WizBang.
I did look in MS KnowledgeBase but found nothing for Win98 regedit command line parameters
Anyway, it's pretty wierd--I don't know why I can't duplicate your instructions... hell they're easy enough to follow--UNLESS--are you applying this command in pure DOS mode? I didn't try that permutation... Drop me a line if you got any ideas. Until then, I'm sticking with the [DelReg] function in .INF files.
What I have since realized is that the /D only works in DOS mode. It will not work in a DOS prompt or from the Windows Run prompt or it will give you the import errors. It also fails in a batch file. I will keep looking. I know it can be done through VB or Pearl, so there has to be a way to do it in a batch file.
07-20-1999, 08:42 AM
There is a free Regdel dos program for you to delete registry keys/values from batch file at http://www.softseek.com/Utilities/Registry_Editors_and_Utilities/Review_23570_index.html .
For a more complete one(including set, get and delete keys/values,) try out Qreg from http://www.q32.com/qreg.htm , but it's a shareware and no documentation for the free trial program.
07-21-1999, 06:53 PM
I have been following this thread.. this is great.. one question..
Has anyone considered writing a C program including windows.h file to edit the registry??
I did this at my school to kick the admins' ***
07-30-1999, 11:55 PM
This is really good!! How do you execute an .INF file?
07-31-1999, 05:57 PM
See my post dated July 5 12:22 for piping the inf file thru rundll. Use this at the DOS command line or with the Start Menu|Run. Otherwise you can also right-click on an .inf file and select "Install"--the default action is usually "edit" so you don't accidentally execute the file by clicking on it.
12-16-1999, 09:29 PM
So is this valid?
HKCU,Software\Microsoft\"Internet Explorer"\Main\"Window Title"
or am I missing something. I haven't been able to get this technique to work yet.
12-17-1999, 04:03 AM
I think it should be like this:
The " were in the wrong place it looked like.
What do you think jstolz?
12-17-1999, 05:31 AM
I also had the problem with the /d switch for regedit. See my post (from Dec 16) for another solution. Basically, add a line in your autoexec.bat or wherever:
start regedit /s c:\...\delete_me.reg
the delete_me.reg file should contain the key but with a minus infront of it (see the answer to my post for an example). I don't think you need the start infront- I just toss it in there. I use this to delete the TypedUrls key from the registry and it works great. Thank Fastway if it works for you because he provided me with the solution.
12-20-1999, 05:00 PM
I tried that syntax and with and without the space between Internet and Explorer. No dice.
12-21-1999, 03:39 AM
I think I was right and the quotes go around only that subkey which has a space character. Of course, it's easy enough to test... just create a n inf file that adds a bogus key using the quotes your way and mine and see which works...
12-27-1999, 04:47 PM
Neat trick, but would it be possible to delete or modify changes with the DYN_DATA section? Unless I was misinformed, someone told me that there is no way that this section can be changed. Since this is kinda going through a different route, I was hoping it may work. What do you think?
If I wanted to delete a certain value (ex. Arial) in HKLM,SOFTWARE\Microsoft\Windows\currentVersion\Fon ts using a inf file. Would I make a entry like HKLM,SOFTWARE\Microsoft\Windows\currentVersion\Fon ts\[Arial]
; DelReg = RegChange
I want to be able to just delete the one value not all of the values in the Fonts Key
Thanks for any help
It Can't Rain All The Time.
-Eric Draven (The Crow)
10-12-2000, 10:06 AM
I did a grep on the C:\WinNT\INF directory for the "Signature" string, and found that most files uses the "Chicago" signature.
That proves the Win9x inf files are probably compatible with NT (for the most trivial of them, of course, some operations can be system specific).
Indeed, I use the same DosHere.inf file (from the PowerToys) for both systems.
Now, if you want the NT specific signature, it is simply the "Windows NT" one.
But I suspect this signature is overlooked by the system in most cases.
And to answer AR-15 below, I don't think it is useful to change anything in the DYN_DATA section. As far as I know, as its name imply, this section stores only dynamic data updated automatically by Windows.
10-12-2000, 10:44 AM
I post it here, to have all references in the same thread...
To delete a registry *KEY* with a .reg file (not a value, only a whole key with its sub-keys and value):
[-HKEY_CLASSES_ROOT\htmlfile\shell\Edit with a stupid editor]
Note the minus sign before the key name.
10-12-2000, 04:06 PM
I have a made a program where you'd save registry key deletion/writing lines in a file. Load them when ever you want, and press a button to delete/write them.