Wednesday, July 16, 2014

Create User Account as desired using C sharp - Console Application

To create User Account as desired using C sharp Console Application

Here is a code


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Diagnostics;



namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Do You want to create a user ID in your system?");
            string st = Console.ReadLine();
            if (st == "yes")
            {
                Console.WriteLine("Enter the name of the user to be create:");
                string user = Console.ReadLine();
                Console.WriteLine("Enter the password:");
                string password = Console.ReadLine();
                string userdetails = "@/C" + " " + "net user" + " " + user + " " + password + " " + "/add";
                Process.Start("cmd.exe", userdetails);
                Console.WriteLine("User has been created succesfully");
                Process.Start("cmd.exe", @"/C pause");
            }
            else
                           
               Console.WriteLine("Thank for you not interested in to create user accounts");
                      
           
        }
    }
}

--- If you want to find out whether user account has been created

Press Windows + R
=> cmd
=> net user
Here you will find list of user accounts created

--Happy Coding--

No comments:

Post a Comment