Windows probably is the only operating system that has a separate database of configuration instructions and paths. The windows registry looks exactly like a giant nested association. Also probably is the fastest and most efficient key-value store there is which is read and written to in real-time. Is there a way to import the Windows registry into a Mathematica association?

The keys of the registry are basic string which Mathematica support and values can be any of the following:

  • Binary data
  • Unsigned integers
  • Symbolic links
  • Multi-string values
  • Resource list / Resource descriptor (Plug and play hardware)
  • 64 bit-integers

Mathematica has a very powerful query language which can then be used to analyse it.

  • $\begingroup$ What have you tried thus far? Do you have an example of a block of registry entries that someone could use instead of having to find one themselves? $\endgroup$
    – b3m2a1
    May 30, 2019 at 15:15
  • $\begingroup$ @b3m2a1 Well I tried to use the built in registry editor to export it as a json but there is no such option. $\endgroup$
    – user13892
    May 30, 2019 at 15:27
  • 4
    $\begingroup$ Check ?Developer`*Registry*, for example Developer`EnumerateRegistrySubkeys["HKEY_CLASSES_ROOT"]. $\endgroup$ May 30, 2019 at 15:33
  • $\begingroup$ Also note that there are hidden keys in the Windows registry. You can access them only having appropriate permissions. $\endgroup$ May 30, 2019 at 15:44
  • $\begingroup$ @AlexeyPopkov Thank you it works but is there a way to get the entire hive structure so I can perform queries like keys with values matching a certain criterion. This functionality only accesses the registry one level at a time. $\endgroup$
    – user13892
    May 30, 2019 at 15:49

1 Answer 1


I agree that it would be nice if we could import the registry as a nested association. This is really not an answer to that, but I thought it might still be useful to others.

I discovered this post in a search. I was looking for a way to read the value of a registry key from Mathematica. (I needed the path to a data directory of a particular installed software tool.) After a bit of hunting, I came upon the fact that Microsoft .NET includes a class named Registry which provides static methods for manipulating the registry. I found the assembly containing that class on my computer.

The code below uses Mathematica's NET/Link to interface with that class and read the value of a registry key. (I used a common key for this post, so others can run the code.)

Information on NET/Link can be found here.

Information on the Registry class can be found here.

And here is the code: (There are a few continuation \ to remove. )

(* Install NETLink *)



(* Load the assembly that contains the Registry class *)
(* I found the location by searching for it on my computer *)

asmName = 
  "C:\\Program \

asm = LoadNETAssembly[asmName];

(* Since this we will use static methods we will not insantiate a \
Registry object, so we need to load the type explicitly *)

registryType = LoadNETType["Microsoft.Win32.Registry"];

(* we can use NETTypeInfo to see the fields and methods *)
(* I deleted the output before posting because its lengthy *)


(* output deleted *)

(* one of the functions is GetValue *)
(* here we use it to get the value of a key *)

key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows \

valueName = "SystemRoot";

systemRootPath = Registry`GetValue[key, valueName, -1]

(* "C:\\windows" *)
  • $\begingroup$ "SystemRoot" /. Developer`ReadRegistryKeyValues[ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows \ NT\\CurrentVersion"] also gives "C:\\WINDOWS" $\endgroup$ Apr 27, 2020 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.