What’s the best way to programmatically merge a .reg file into the registry? This is for unit testing; the .reg file is a test artifact which will be added then removed at the start and end of testing.
Or, if there’s a better way to unit test against the registry…
It is possible to remove registry keys using a .reg file, although I’m not sure how well it’s documented. Here’s how:
The
-in front of the key name tellsRegeditthat you want to remove the key.To run this silently, type: