[Windows] Let's set automatic logon in the registry!Introducing command and batch file creation examples!

Tips / Knowledge

Hello!This time, I would like to introduce the setting method for automatically logging on to Windows!

Automatic logon is usually not recommended as it can be very insecure in practice.It's natural because anyone can use it.

However, login can sometimes be a barrier, such as when you have a computer installed in a shared location or when you want to perform batch processing automatically.

In such a case, it is an effective method to set automatic login so that the login screen does not stay stuck.It's not a very compliment, but you can start using it non-stop once you turn it on.

I will show you how to enable such automatic logon!

Thing you want to do

When I turn on the computer, I want to log on to Windows automatically so that the desktop can be displayed.

I would like to omit user selection and password entry so that Windows can be used immediately.

Command example

Enable automatic logon

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_DWORD /d "1" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /t REG_SZ /d "%USERNAME%" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /t REG_SZ /d "%PASSWORD%" /f

* Enter the user name you want to log in automatically in% USERNAME% and the password of that user in% PASSWORD%.
* When executing, use the command line executed with administrator privileges.

If you restart after the command is completed normally, login to Windows will be completed without entering a password, so please check it.

Disable automatic logon

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_DWORD /d "0" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /f
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /f

If you restart after the command is completed normally, the password input screen will be displayed as usual when logging in to Windows.please make sure.


All settings for automatic logon can be completed in the registry.
The registry key is stored in "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon".

Checking with the registry editor

I would like to explain these three keys.

* "Default Passowrd" is a registry key that does not exist if nothing is done.To set automatic logon with the registry editor, create it manually by referring to the following.

Registry to enable automatic login

First of all, it is necessary to set the "AutoAdminLogon" key as a registry to enable the function.

The "AutoAdminLogon" key is a registry of integer values.
The meaning of the registry value is "XNUMX = invalid, XNUMX = valid".

If you want to enable automatic logon, start by setting this registry key to "XNUMX".

If this setting is used as a command, it will be as shown below, as described in the command example.

reg add "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon" / v "AutoAdminLogon" / t REG_DWORD / d "1" / f

Registry that specifies the user to log in automatically

Next, specify the user who will automatically log in.The user specification is stored in "DefaultUserName".

"DefaultUserName" is a registry of strings.
Automatic login is performed with the user name stored in this registry.

You can check the user name on the "Computer Management" screen, or by "echoing" "% USERNAME%" as the logged-in user.You can only log in with the registered user name, so please check if you have changed the display name.

"Computer Management"Win key+XI think it's easiest to press and click Manage Computers.

To check with "echo", execute the following command on the command line of the user who wants to log in.
If you want to start the command lineWin key+XI think you can press and click "PowerShell" or "Command Prompt".


If you want to register the currently logged-in user, "% USERNAME%" will reflect the current user name as it is, so you can register with the following command.

reg add "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon" / v "DefaultUserName" / t REG_SZ / d "% USERNAME%" / f

Registry that specifies the password to use for automatic login

Finally, the password.The password is stored in the "Default Password" key.

"DefaultPassword" is a string registry key.
By entering the password of the user name you set earlier, Windows will even enter the password at startup.

It does not exist in the initial state, so if you want to set it manually, you need to create it.

If you want to set it manually, right-click in the empty space of the registry editor and a menu will appear. Click "New"-> "String value" and name the registry key "DefaultPassword". Please give me.

Click "New"-> "String Value"
Rename the new registry key to "DefaultPassword" and press "Enter" to complete the creation.

Double-click the completed registry key to open it, enter the password in "Value data", and click "OK" to complete the password setting.

The following command summarizes these tasks.
* Replace "% PASSWORD%" with the password of the user who logs on.

reg add "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon" / v "DefaultPassword" / t REG_SZ / d "% PASSWORD%" / f

One caveat is that this password is not encrypted.
Therefore, if you start the Registry Editor on a computer that has automatic logon enabled and see this value, the password will be leaked.Please be careful.

Disable automatic logon

To disable it, set the "AutoAdminLogon" key to "XNUMX" and delete the "DefaultUserName" and "DefaultPassword" keys.

In particular, if you leave the "Default Password" key in place, the password will be visible in the registry, so be sure to delete it if you don't need it!


This time, I introduced how to automate Windows login.

Automating login is not highly recommended from a security standpoint.
However, when using a batch file etc., the process will stop if you return to the login screen by restarting.It is also a useful method in such cases.

That said, I find it a bit appealing to be able to boot Windows without entering a password.
It usually takes about 10 seconds to enter the password, so if you enter it 1 times in your lifetime, you will save about 28 hours. I think it will save more than a day (sweat)

I hope it helps you!

Reference site

Configure Windows Logon-Windows Server
This article describes how to edit the registry to enable the Windows logon feature.

Thank you!


Translate »
I copied the title and URL