I am having trouble with some batch commands that are used to edit different registry keys. The keys being deleted and changed are:

REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f

REG DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /f

REG DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /f

REG DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /f

My problem is consistency. Sometimes these keys are deleted/changed, but sometimes I will come back to the computer after a long install and see that the computer is still attempting to login with a default username and password. I have also found a couple other keys throughout my scripts that behave inconsistently.

Anyone have any thoughts on this? I have even edited my scripts to execute these commands multiple times with timeouts in between. This has cut down on the problem, but has not solved it all together.
Answer Summary:
0 Comments   [ + ] Show Comments


Please log in to comment

Answer Chosen by the Author

use start /wait in front of each line

here is a sample add file I use

Start /wait net user administrator Password 
Start /wait net user 2nduser Password
start /wait net localgroup administrators 2nduser /add

start /wait cscript %SystemRoot%\System32\slmgr.vbs -ATO

start /wait powershell set-netconnectionprofile -name "admn.acme.edu" -networkcategory private

start /wait reg.exe DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /f

start /wait reg.exe DELETE "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Send To OneNote 2013" /f

start /wait cscript "c:\program files (x86)\microsoft office\office16\ospp.vbs" /act

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoAdminLogon /d 1 /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoLogonCount /t REG_DWORD /d 2 /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultUserName /d Administrator /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultPassWord /d Password /f
start /wait reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultDomainName /f

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableFirstLogonAnimation /d 00000000 /t REG_DWORD /f

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /d 00000000 /t REG_DWORD /f

start /wait reg.exe add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v kaceinstall /d "msiexec /qn /i \\kbox\client\agent_provisioning\windows_platform\ampagent-6.4.522-x86.msi HOST=kbox.tmcc.edu"

Here is a stop autologin script

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoAdminLogon /d 0 /f

start /wait reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v defaultpassword /f

You can delete the other two keys but that does not really matter, the above are the necessary keys

Answered 05/25/2016 by: SMal.tmcc
Red Belt

  • Thanks, I don't know why I was not already doing this - I was already doing it for software installs. I guess I just didn't think that a few milliseconds would make a huge difference. Thanks again.
Please log in to comment


Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja