Delete user account from command line

We can use the below commands to delete a user account using Windows command prompt.

To delete a user account of the local system

Open Command Prompt as administrator. Replace username with the account name; use double quotes if it contains spaces.
Before deleting the account, back up any files you need and make sure you can sign in with another administrator account.

Advertisement
net user username /DELETE

To delete a user account from domain

net user username /DELETE /DOMAIN

You need permission to delete the account in the domain, either through domain administrator rights or delegated permissions. Note that we do not need to specify the domain name in this command. The /DOMAIN switch sends the operation to a domain controller in the computer’s primary domain, so that domain must be reachable.

The commands work on Windows 11 and Windows 10 as well as older Windows releases such as Windows 7, Windows 8 and XP. They are also available on Windows Server.

We can check whether a local account still exists with net user username. For a domain account, use net user username /DOMAIN.

Deleting an account is separate from cleaning up its saved user profile. If you also need to remove that profile, see Microsoft’s instructions for deleting a user profile.

Advertisement

11 thoughts on “Delete user account from command line”

  1. not sure how old this post is but if you are able to respond.. I have an issue. I have a laptop that has been used in an onsite network and a mutual vpn. I have enabled the net user administrators account but I noticed that the drive that is shown is X: I went to C: to do all my work so far, so I am on C:\windows\system32. I want to do away with the profile X: since it is controlling the login. How can I remove the network profile as well as the VPN environment thru the command prompt? This is a upgraded windows 10 environment.. thanks

    Reply
    • The X: drive is typically a virtual drive created in memory just for the purpose of temporary storage for that session. It is deleted and removed when you close the session.

  2. i have error
    “the connection was denied because the user account is not authorized for remote login”
    how do i enable remote desktop session after adding new user account?

    Reply
  3. @Edward Allington
    I would suggest you use quotes around the usernames with spaces. I.e. net user “Jack Smith” /delete /Domain

    Reply
  4. This command works for me with accounts without spaces in their names, but in accounts with spaces in their names, it says:
    The syntax of this command is:

    NET USER
    [username [password | *] [options]] [/DOMAIN]
    username {password | *} /ADD [options] [/DOMAIN]
    username [/DELETE] [/DOMAIN]
    username [/TIMES:{times | ALL}]

    Why doesn’t it work?

    Reply

Leave a Comment