Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 656575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:43:44+00:00 2026-05-13T22:43:44+00:00

I am doing a C# application targeting WinXP, Vista, and 7 Operating Systems. One

  • 0

I am doing a C# application targeting WinXP, Vista, and 7 Operating Systems.

One feature is, I can Add, Remove, Modify the Group set to a user programmatically.

Can I ask for help how to make this happen?

Will it be possible to do this in WMI? My codes mainly using WMI to get the users..


Currently am using Windows7

I am trying to test this code

DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",Computer");
localMachine.Properties["member"].Add("Chevi");
localMachine.CommitChanges();
localMachine.Close();

and it’s spitting this error

The directory property cannot be found in the cache.

I tried enumerating the Property collection and I got this

OperatingSystem

OperatingSystemVersion

Owner

Division

ProcessorCount

Processor

Name
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:43:45+00:00Added an answer on May 13, 2026 at 10:43 pm

    If you’re using local groups, you can do this by calling the system net command. For example, to add a user to a group, you’d call:

    net localgroup MyGroup /add SomeUser
    

    Type net help localgroup at a command prompt for more info.

    You can also do this using WMI. This is VBScript but can be adapted to .NET or your preferred programming toolkit:

    Dim oComputer
    Computer = "computername"
    Groupname = "Administrators"
    ObjectToAdd = "Administrator"
    
    ' Bind to the computer.
    Set oComputer = GetObject("WinNT://" & Computer & ",computer")
    
    ' get group object
    Dim oGroup
    Set oGroup = oComputer.GetObject("group", GroupName)
    
    ' Add the user object to the group.
    oGroup.Add "WinNT://" & Computer & "/" & ObjectToAdd 
    

    Credit: Matt Hickman, http://www.tech-archive.net/Archive/WinXP/microsoft.public.windowsxp.wmi/2004-04/0007.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some research on the feasibility of an iPhone application, and can't find
People always advised me that if I am doing some application that should use
I'm on a project doing an iPhone application. We had a Cocoa consultant come
I was curious as to what other shops are doing regarding base application frameworks?
My application links against libsamplerate.a. I am doing this to make distributing the final
I have a winforms application that is doing the following: on each query: Db
I am doing an Financial Winforms application and am having some trouble with the
I'm doing a authorization check from a WinForms application with the help of the
Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application I got
I am doing some maintenance on a VB6 Windows application. I have a .Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.