Skip to main content
InSource Solutions

TN WW207 Auto-Locking a Windows Account upon Boot

InSource_Logo_Transparent (1).pngCount5.JPG




This article from InSource shows how to have an account automatically locked out as soon as a user first logs on.

  • Author: Joseph Hefner
  • Published: 05/30/2018
  • Applies to: All


Sometimes it might be necessary to have an account automatically startup upon boot and lock the logged in account. This can be necessary if software cannot run as a windows service but needs to be running every time the computer boots up. Below are the steps to automatically logout a user upon initial logon.


Step 1) Open up a new notepad.



Step 2) Type the following:

rundll32.exe user32.dll,LockWorkStation



Step 3) Save as a bat file:


Step 4) Place the bat file into the startup folder at the locations below.  These locations may be different depending on the Operating System:

  • C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp