Batch file to delete a registry key

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.
 
D

Dave Patrick

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
 
M

Mark V

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...
 
J

JeffO

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top