/build/static/layout/Breadcrumb_cap_w.png

Batch File Inconsistently Editing Registry

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.

0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: SMal.tmcc 7 years ago
Red Belt
0

Top Answer

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


Comments:
  • 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. - trw68319 7 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ