'Adding user to local administrators group via CMD does not seem to work
I am trying to add a user to the local administrators group via my windows form app.
So in my Windows Form App I create the user in Active Directory (this part works great) then once the user is added the computer gets added to the domain (this part works great as well), then I need to add the user to the local administrator group on the computer (this is where it doesn't work)
So what I have is:
Process cmd = new Process();
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.Arguments = "/C net localgroup administrators " + txt_LogonName.Text + " /add";
cmd.StartInfo.Arguments = "pause";
cmd.StartInfo.CreateNoWindow = false;
cmd.StartInfo.RedirectStandardInput = true;
cmd.Start();
the txt_LogonName.Text is where I specify the user details. IE domain\user
So normally running this command from CMD as admin
net localgroup administrators domain\user /add
works great, but does not want to run in my windows app.
Any ideas why?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
