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

  • SEARCH
  • Home
  • 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

hi i am doing one application here i need to disply 6 images in
i am doing one small application , wheich have login functionality, in the user
I am doing one application using proximity sensor in android. when any object(finger) comes
I am doing one application, and because of security, I need to know that
Iam doing one application .In that i want to find out the x,y,z axis
I am doing application with parsing XML file. I used TransformerFactory to modify XML
I'm doing one application like raising email intent by time using AlarmManager . In
I am doing application and I need to dispaly some images in a gridview.
im doing an application in which im transfering file through FTP.i succesfully done all
I am doing an application in Yii Framework.I have progressed to some way like

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.