add/update windows users – windows user management

Sometimes, we may need to add/update the windows user management functionality in our windows application or windows service. In such cases, we can just use the ‘net user’ functionality of the windows operating system. Refer the below command to perform user operations.

NET USER
[username [password | *] [options]] [/
username {password | *} /ADD
username [/DELETE] [/DOMAIN]

We can easily fire these commands using Process .NET class. Refer the examples in C# below

Process p = System.Diagnostics.Process.Start(“c:\\windows\\system32\\net”,”user username newpassword”.
//This will update the user username with the password newpassword

Process p = System.Diagnostics.Process.Start(“c:\\windows\\system32\\net”,”user username newpassword /ADD”.
//This will add a new user wth username username and password newpassword

The second arcument of above start function are the arguments to the command “net”

Mayur Gondaliya - CTO - CaseTronyx, Inc. Director - ExaSpring Information Services Pvt. Ltd. Web Investor. Software Engineer. Workaholic. Insomniac.

Leave a Reply