Please use the include Msf::Post::Windows::Registry mixin to access the Windows Registry from a Post module always when possible. The usage of the Msf::Post mixins for post exploitation is preferred since they try to be compatible with different type of sessions (and platforms) when possible.