In the last post, I illustrated a module that retrieves the User, Domain and SID from the Windows System.Management namespace. In this post, I'm showing a practical application for that module.
This utility can be used if a user finds that access to the system registry or add/remove programs has been accidentally denied. Of course, this can also be done with a VBS script (run with Wscript.exe).
Potential error messages:
- Registry editing has been disabled by your administrator.
- Add or Remove Programs has been restricted. Please check with your administrator.


This was created with Visual Studio Standard 2008 and at least .NET 2.0.
using System;
using Microsoft.Win32;
using UserDomainSid; //...from previous post
namespace RegRelease
{
class CRegRelease
{
public static string GetSid()
{
CUdsObj uds = CUserDomainSid.GetUDS();
return uds.strSID;
}
static void Main(string[] args)
{
string strSid = GetSid();
Registry.SetValue(
@"HKEY_USERS\" + strSid +
@"\Software\Microsoft\Windows\CurrentVersion\Policies\System",
"DisableRegistryTools", 0, RegistryValueKind.DWord);
Registry.SetValue(
@"HKEY_USERS\" + strSid +
@"\Software\Microsoft\Windows\CurrentVersion\Policies\Uninstall",
"NoAddRemovePrograms", 0, RegistryValueKind.DWord);
}
}
}