Batch file to delete a registry key

  • Thread starter Thread starter Larry
  • Start date Start date
L

Larry

Hi,

Anyone knows what are the commands for a batch file to
delete a key from the registry when all the users log on
to their own pc. We are having problems with virus all
over the network. It would be easier to just create a
batch file to delete the dllhost.exe from the registry.
 
If you want to remove a key and all it's underlying values then you'll need
to construct your .reg file with a - minus sign in front of the key you want
to remove.

An example file to remove a file association .zzz from HKCR
-----------------Begin File-----------
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\.zzz]
----------------End File-------------

(note the minus sign in front of HKEY)


If you need to delete only certain values, for example the string value
"InfoTip"="Contains zzz files"

Then put a minus sign after the equals sign without "quotes", something like
"InfoTip"=-

So your .reg file would look like
----------------Begin File------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.zzz]
"InfoTip"=-
----------------End File-------------

regedit /s filename.reg to import silently
 
Larry wrote in
Hi,

Anyone knows what are the commands for a batch file to
delete a key from the registry when all the users log on
to their own pc. We are having problems with virus all
over the network. It would be easier to just create a
batch file to delete the dllhost.exe from the registry.

That does not sound to me like a sensible way to remove a virus...
The A-V vendors usually release removal tools that would be (IMO) a
safer option. But Dave posted the answer.

But the Users may not have sufficient permission to the registry key...
 
It is actually a great protection.
Our network is doing okay because we have multiple layers
of protection. I've considered doing the same thing but
haven't yet.

If a tech inserts a line in the HKLM Run key that launches
a batch file. This could be put on every departmental PC.
Next, the tech could distribute a batch file to every PC.
Between the reliable reg/run and the batch file, there's
all sorts of forced options that can be enforced.
In class, changing just one Group Policy setting caused a
very noticable slow-down in boot-up times. (It's already
slow enough with SMS, auditing components, antivirus,
etc.) A tiny batch script runs so fast it usually never
shows on the screen. I killed Hotbar and Gator on one
belligerant user's PC this way until she gave up trying to
install them.

Whenever the tech wants to add or change anything, they
just edit the batch script and copy whatever else is
necessary. It would be better to keep the batch script and
any packages in a hidden folder.

Taking what Dave Patrick said and using a batch script to
import a reg file, the batch code might look like this:
regedit /s C:\WINNT\DEPT\KillIt.reg
KillIt.reg would have your entries that delete the keys or
values. REGEDIT /s is the silent mode. It'll happen so
fast, nothing will even flash on the screen.
 
Back
Top