Run as Normal User (RANU)
Running as a Normal User (RANU)
Programs that write to the local machine branch (HKLM) of the system registry require administrative permissions. The Visual Studio 2008 SDK is designed to enable VSPackage development without requiring administrative rights. Instead, VSPackage developers can run as normal users (RANU).
Beginning in the Visual Studio 2008 SDK, the experimental hive has been moved from the HKLM branch to the current user branch (HKCU) of the system registry. The locations are shown in the following table.
System Registry Branch |
Meaning |
---|---|
HKLM\Software\Microsoft\VisualStudio\9.0 |
Normal hive. |
HKCU\Software\Microsoft\VisualStudio\9.0 |
Normal user settings. |
HKCU\Software\Microsoft\VisualStudio\9.0 Exp\UserSettings |
User settings for experimental build. These include font cache, colors, window size, and location. |
HKCU\Software\Microsoft\VisualStudio\9.0 Exp\Configuration |
Experimental hive. |
In addition, /RANU switches have been added to devenv.exe, RegPkg.exe, and other Visual Studio SDK utilities. When devenv.exe is started by using the /RANU switch, Visual Studio examines the HKCU branch for registered VSPackages, menus, and so forth.
Although these changes are intended to be invisible to the VSPackage developer, deployment of a VSPackage to another computer still requires administrative credentials.
Note
When the Visual Studio SDK is first installed it creates an experimental hive for the current developer. To add an experimental hive for another developer, click Start then All Programs, then Visual Studio 2008 SDK, then Tools, and then click Reset the Visual Studio 2008 Experimental Hive.
Registering Assemblies in the GAC
If you want your assemblies to be registered in the GAC, you need to run as an administrative user. In the project file set the property GacTargetOutput to true and the property RegisterWithCodebase to false, and the property RegisterWithRANU to false. In addition, , run the following vsregex command in an elevated command shell to set up the experimental hive:
vsregex getorig 9.0 exp
Discovering and Modifying Registry Keys
If you need to modify HKLM registry settings, you must do so as an administrative user.
If you need to discover which registry hive Visual Studio is using, you can use the following methods.
In the Managed Package Framework, two properties of the Package class, ApplicationRegistryRoot and UserRegistryRoot, are RegistryKey objects that show the current registry hive. The ApplicationRegistryRoot property returns
HKCU\Software\Microsoft\VisualStudio\9.0Exp\Configuration
if the application is currently being run as a normal user, but
HKLM\Software\Microsoft\VisualStudio\9.0Exp\Configuration
if the application is currently being run as an administrative user (without the /ranu switch). UserRegistryRoot returns
HKCU\Software\Microsoft\VisualStudio\9.0Exp\UserSettings
in both cases.
If you are using native code, you can use the ILocalRegistry4::GetLocalRegistryRootEx method, passing in either __VsLocalRegistryType.RegType_Configuration for the application root, or __VsLocalRegistryType.RegType_UserSettings for the user settings root.
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Rewrote and refactored project. |
Content bug fix. |