Click here to Skip to main content
15,888,454 members
Articles / Programming Languages / C#

Reset Windows Administrator Account Password in C#

Rate me:
Please Sign up or sign in to vote.
2.70/5 (36 votes)
14 Nov 2010GPL3 118.3K   57   26
How to Reset Windows Administrator Account Password in C# (Silently)

Introduction

By using this technique you can reset the Windows Administration Account password to what ever you want. In addition, with some changes, you can also reset other Windows Account passwords. However, the most importent point of this technique is that the method runs silently (hidden) and does not show the CMD Window. I hope this is useful to you!

Using the code

Just copy and paste the following code into your Project.

C#
using System.Diagnostics; 
//
private static void ResetAdminPass(string NewPass)
{
    //Create New Process
    Process QProc = new Process();

    // Do Something To hide Command(cmd) Window
    QProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    QProc.StartInfo.CreateNoWindow = true;

    // Call Net.exe
    QProc.StartInfo.WorkingDirectory = "C:\\windows\\SYSTEM32";
    QProc.StartInfo.FileName = "net.exe";
    QProc.StartInfo.UseShellExecute = false;
    QProc.StartInfo.RedirectStandardError = true;
    QProc.StartInfo.RedirectStandardInput = true;
    QProc.StartInfo.RedirectStandardOutput = true;

    // Prepare Command for Exec
    QProc.StartInfo.Arguments = @" user administrator " + NewPass;
    QProc.Start();

    // MyProc.WaitForExit();
    QProc.Close();
}
//

For example you can create a Windows Forms Application (C#) and in Form_Load() do this:

C#
private void Form1_Load(object sender, EventArgs e)
{
    ResetAdminPass("12345ABC");
}

Note that you can simply change "administrator" to what ever you like and reset that account instead.

Points of Interest

I use this code snippet in my project to help my clients so that each time they change their password in my program, their Windows Administrator Account password changes, too!

I hope this is useful to you!

History

Version 1.0

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Team Leader
Iran (Islamic Republic of) Iran (Islamic Republic of)
Ghasem - Nobari
Qasem*AT*SQNco.com

Comments and Discussions

 
GeneralRe: That's Great Pin
gplabivf30-Apr-07 13:42
gplabivf30-Apr-07 13:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.