# Script to enable Windows automatic logon for screenless kiosk

Automatic logon in Windows is a feature that makes a specific user account accessible on the device without entering the username and password. This feature enables quick access to the device and in screenless kiosks, which don’t rely on display screens for user interaction. Instead, they utilize other input/output mechanisms like voice commands, RFID scanners, or physical buttons.

For screenless kiosks, administrators can set up auto logon with the help of a custom script. When setting up automatic logon for Windows screenless kiosk, it’s important to note that only the specific user account designated for the kiosk mode is accessible, with other user accounts remaining inaccessible. This script also ensures that devices never enter sleep mode.

Screenless kiosk mode with automatic logon can be integrated into both the [single app kiosk](https://www.hexnode.com/mobile-device-management/help/how-to-lock-down-windows-devices-to-a-single-app-kiosk-mode/) and [multi app kiosk](https://www.hexnode.com/mobile-device-management/help/how-to-lock-down-windows-devices-in-multi-app-kiosk-mode-using-hexnode/) features provided by Hexnode UEM. To enable screenless kiosk mode for a specific user account, IT administrators can deploy the necessary kiosk policy to the target device using Hexnode UEM. Once the policy is in place, they can execute the script to automate the user account login via the [Execute Custom Script](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/) remote action.

Scripting language – PowerShell

File extension – .ps1

 Disclaimer: 
The sample script provided below is adapted from a third-party open-source site.

 

Turn on automatic logon in Windows
----------------------------------

Here, the PowerShell script is designed to simplify the specific user account login and power settings on a Windows system. Replace Username and Password with the actual username and password of the kiosk user account whose login needs to be automated.

Powershell script to turn on automatic logon in Windows

$Username = "Username" $Password = "Password" $RegPath = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" Set-ItemProperty -Path $RegPath -Name "AutoAdminLogon" -Value 1 Set-ItemProperty -Path $RegPath -Name "DefaultUsername" -Value $Username Set-ItemProperty -Path $RegPath -Name "DefaultPassword" -Value $Password New-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI" -Name "LogonUserSwitch" -Value 0 -Force powercfg -change -monitor-timeout-ac 0 powercfg -change -monitor-timeout-dc 0 powercfg -change -standby-timeout-ac 0 powercfg -change -standby-timeout-dc 0 Restart-Computer -Force

   1

2

3

4

5

6

7

8

9

10

11

12

  $Username = "Username"

$Password = "Password"

$RegPath = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"

Set-ItemProperty -Path $RegPath -Name "AutoAdminLogon" -Value 1

Set-ItemProperty -Path $RegPath -Name "DefaultUsername" -Value $Username 

Set-ItemProperty -Path $RegPath -Name "DefaultPassword" -Value $Password 

New-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI" -Name "LogonUserSwitch" -Value 0 -Force 

powercfg -change -monitor-timeout-ac 0

powercfg -change -monitor-timeout-dc 0

powercfg -change -standby-timeout-ac 0

powercfg -change -standby-timeout-dc 0

Restart-Computer -Force

   

 

  

The script uses the Windows Registry, specifically targeting the path **HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon** to automate the user login by setting **AutoAdminLogon** to **1** and specifying the user account’s credentials with **DefaultUsername** and **DefaultPassword**.

Additionally, it creates a registry key under **HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI** to disable user account switching during login. The script further customizes power settings using **powercfg** commands, setting timeout to 0 to prevent the device from entering standby due to inactivity. Finally, the script forcefully restarts the computer with the help of **Restart-Computer –Force** command to apply the configured changes.

What happens at the device end?
-------------------------------

Upon successful execution of the script, the device will restart, and automatically log into the specified kiosk user account without requiring the username and password, thus activating kiosk mode.

[![Portal output after implementing automatic logon for screenless kiosk on windows devices](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2024/06/Output-of-the-script-that-enables-automatic-logon-for-Windows-screenless-kiosk.png "Output of the script that enables automatic logon for Windows screenless kiosk")](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2024/06/Output-of-the-script-that-enables-automatic-logon-for-Windows-screenless-kiosk.png)

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.