In my organization, our passwords expire every 90 days. For certain users, we have Auto-Logon to Windows configured, but a technician has to reconfigure the registry each time the user's password changes.
I'd like to create a *single* Batch file that prompts the user for their new password, and then modifies the appropriate registry key so their Auto-Logon can be reconfigured without intervention from a PC Tech.
Is this possible without having to import a separate .REG file from within the batch?
I've tinkered with it a bit, and it seems like I'm getting close, but I can't get the Registry modified within an IF statement.
Here's what I've created so far. (I know it's far from complete, but bear with me for proof of concept)
Code: Select all
REGEDIT4
; @ECHO OFF
; CLS
; REGEDIT.EXE /S "%~f0"
@echo off
:choice
set /P c=Would you like to update your Windows Auto-Logon Password?[Y/N]?
if /I "%c%" EQU "Y" goto :answered_yes
if /I "%c%" EQU "N" goto :answered_no
goto :choice
:answered_yes
echo Let's update your password...
set /P newpw=Please enter your new Windows password:
cls
echo Your password has been updated
pause
:: Now Update in Registry
goto :editRegPW
:answered_no
goto :username
:username
set /P u=Would you like to update your Windows Auto-Logon Username?[Y/N]?
if /I "%u%" EQU "Y" goto :answered_yes_un
if /I "%u%" EQU "N" goto :answered_no_un
:answered_yes_un
echo Let's update your username...
set /P newun=Please enter your new Windows username:
echo Your username has been updated to %newun%
:: Now Update in Registry
goto :editRegUN
pause
:answered_no_un
exit
:editRegPW
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Test]
"DefaultPassword"="Test PW"
"AutoAdminLogon"="1"
pause
goto :username
:editRegUN
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Test]
"DefaultUserName"="Test UN"
"DefaultDomain"="Test DOM"
"AutoAdminLogon"="1"
exit
In case it's not obvious, I'm fairly new to Batch files.
Thanks in advance for any advice!
Cameron