Utility that uses the CUserDomainSid class

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:

  1. Registry editing has been disabled by your administrator.
  2. Add or Remove Programs has been restricted. Please check with your administrator.

Registry editing has been disabled
Add or Remove Programs restricted

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);
      }
   }

}

 

posted @ Thursday, January 7, 2010 10:53 PM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)

 
 
 
 

Live Comment Preview:

 
«October»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567