@echo off
if exist "C:\Documents and Settings\%1\ntuser.dat" (
echo ** Attempting to load the user settings from %1 into the registry **
reg load HKU\Temp "C:\documents and settings\%1\ntuser.dat"
echo ** Registry hive has been loaded. **
echo ** Attempting to clear keys and re-create needed ones. **
reg delete "HKU\Temp\Software\Microsoft\Windows\CurrentVersion\Group Policy\History" /f
reg add "HKU\Temp\Software\Microsoft\Windows\CurrentVersion\Group Policy\History"
reg add "HKU\Temp\Software\Microsoft\Windows\CurrentVersion\Group Policy\History" /v DCName /t Reg_SZ /d %logonserver%.DOMAIN.COM
echo ** Keys have been cleared. Now unloading registry hive. **
reg unload HKU\Temp
echo ** Registry hive has been unloaded. **
echo ** Forcing Group Policy to reload on reboot. **
gpupdate /force /boot
echo ** Rebooting Computer **
shutdown -r -c "Shutting down PC to re-initialize group policy."
) ELSE (
echo ** ERROR: File not found. Are you sure you entered the username correctly? **
echo ** The username you entered was %1. **
echo ** The proper usage of this script: fixgp.bat username **
)