2009-08-25

Automatic logon script for Windows XP

I have created a command line script for setting the windows registry values to logon automatically in Windows XP. To set these values manually go to a previous post here.

@echo off
echo Automatic Logon in Windows XP

if exist "%SystemRoot%\system32\reg.exe" (
 echo REG.EXE was found...
 goto :runscript
)
goto :exitfail

:runscript
if /i "%1" equ "set" (goto :activelogon) else (if /i "%1" equ "unset" (goto :unactivelogon) else (goto :exitfail))

:activelogon
set /p theuser="Default User Name:"
set /p thepassword="Default User Password:"
echo Running REG.EXE to set the required values...
echo. 
echo Setting DefaultUserName...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /t REG_SZ /d "%theuser%" /f
echo.
echo Setting AutoAdminLogon...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_SZ /d "1" /f
echo.
echo Setting DefaultPassword...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /t REG_SZ /d "%thepassword%" /f
set theuser=
set thepassword=
goto :exitnormal

:unactivelogon
echo Running REG.EXE to delete the required values...
echo.
echo Deleting AutoAdminLogon...
"%SystemRoot%\system32\reg.exe" delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /f
echo.
echo Deleting DefaultPassword...
"%SystemRoot%\system32\reg.exe" delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /f
goto :exitnormal

:exitfail
echo.
echo Failed.
goto :eof
:exitnormal
echo.
echo All operations completed successfully.

You can also download it from the box.

Niciun comentariu: