Skip to content

Instantly share code, notes, and snippets.

@silvercircle
Last active August 23, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silvercircle/f1d6436475f952a8a46daa313fbf086e to your computer and use it in GitHub Desktop.
Save silvercircle/f1d6436475f952a8a46daa313fbf086e to your computer and use it in GitHub Desktop.
remove all components for an installer package from the registry.
module main;
/++
+ whack all compontents for an installed package
+ quick and dirty
+
+ dub build --build=release --compiler=dmd --arch=x86_64
+/
import std.stdio, std.string: indexOf;
import std.windows.registry;
void main(string[] args)
{
version(Windows)
{
//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData
const PID = "659B4F254F646AC4CB6CF8E3D56B5E2D"; // the product-ID.
int i = 0;
Value thisvalue;
Key registryKey = Registry.localMachine()
.getKey("Software")
.getKey("Microsoft")
.getKey("Windows")
.getKey("CurrentVersion")
.getKey("Installer", REGSAM.KEY_ALL_ACCESS)
.getKey("UserData", REGSAM.KEY_ALL_ACCESS)
.getKey("S-1-5-18", REGSAM.KEY_ALL_ACCESS)
.getKey("Components", REGSAM.KEY_ENUMERATE_SUB_KEYS | REGSAM.KEY_ALL_ACCESS);
foreach(ref Key k; registryKey.keys) {
try {
thisvalue = k.getValue(PID);
if(indexOf(thisvalue.value_SZ, "modo13") > 0) {
i++;
writef("Key = %s, Value = %s\n", k.name, thisvalue.value_SZ);
registryKey.deleteKey(k.name);
}
} catch (RegistryException e)
continue;
}
writef("Finished, found %d entries\n", i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment