LISTING 1: First.bat @ECHO OFF REM Identify the client OS. if "%OS%"=="Windows_NT" goto winntscr goto end :winntscr BEGIN CALLOUT A REM Remap network drives to use new user ID credentials. FOR %%I IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO %0\..\reg update HKCU\Network\%%I\UserName="NEWDOMAIN\%USERNAME%" END CALLOUT A REM Add the Migrate user to the local Administrators group. net localgroup administrators OLDDOMAIN\Migrate /add > NUL REM Set environment variables for later use. %0\..\regchg "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" MigrateUser REG_SZ %USERNAME% > NUL %0\..\regchg "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" MigrateProfile REG_SZ %USERPROFILE% > NUL BEGIN CALLOUT B REM Enable automatic logon for the Migrate account. %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" AutoAdminLogon REG_SZ "1" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultUserName REG_SZ "Migrate" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultDomainName REG_SZ "OLDDOMAIN" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultPassword REG_SZ "password" > NUL END CALLOUT B REM Null the shell to lock down Migrate logon. %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Shell REG_SZ "" > NUL BEGIN CALLOUT C REM Tell NT to remain connected via RAS after user logoff so that the scripts can continue to run via RAS. %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" KeepRasConnections REG_SZ "1" > NUL END CALLOUT C :end REM Log user off. %0\..\Logoff.exe