LISTING 2: Second.bat @ECHO OFF BEGIN CALLOUT A REM Move user's original profile to Default User and delete the Registry key associated with the old user account. MOVE "%SystemRoot%\Profiles\Default User" "%SystemRoot%\Profiles\Default Temp" MOVE %MigrateProfile% "%SystemRoot%\Profiles\Default User" REM Add the new user account and new domain's Domain Admins group to the local Administrators group for the migration. net localgroup administrators NEWDOMAIN\%MigrateUser% /add > NUL net localgroup administrators "NEWDOMAIN\Domain Admins" /add > NUL END CALLOUT A REM Disable autologon. %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" AutoAdminLogon REG_SZ "0" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultUserName REG_SZ "%MigrateUser%" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultDomainName REG_SZ "NEWDOMAIN" > NUL %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultPassword REG_SZ "" > NUL REM Replace explorer.exe as the shell. %0\..\regchg "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Shell REG_SZ "Explorer.exe" > NUL BEGIN CALLOUT B REM Execute the domain change. %0\..\netdom /Domain:NEWDOMAIN MEMBER %COMPUTERNAME% /JOINDOMAIN > NUL END CALLOUT B REM Log off the Migrate account. %0\..\Logoff.exe