Sunday, 22 October 2017 17:00

Fix Corrupted Windows Profile

Rate this item
(0 votes)

 

Over the years, I've had various people that have had trouble logging into their Windows computer.  Windows would login to a Temporary profile.  It is an easy fix, but not so easy from a distance since it involves editing the registry.  I don't like sending regedit commands to users since so many things could go wrong.  In response to the many requests I received, I wrote the script below in AutoIT.  It's simple and easy for the user to double-click the executable file after restarting into Safe Mode.  It fixes the Corrupted Profile.  The code isn't pretty, but leave a comment if you find anything that doesn't work.

If you want to learn more about the Windows Temporary Profile, search for:  windows temporary profile fix

I hope this helps someone.

Thanks!


#NoTrayIcon #RequireAdmin #include Opt("TrayMenuMode",3) ;$settingsitem = TrayCreateItem("Settings") ;TrayCreateItem ("") $exititem = TrayCreateItem("Exit") TraySetIcon("Shell32.dll",14) TraySetToolTip("Running Fix Profile") TraySetState() Func CheckMenuItem() $msg = TrayGetMsg() Select Case $msg = $exititem Exit EndSelect EndFunc For $i = 1 To 50 Local $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", $i) CheckMenuItem() If @error <> 0 Then ExitLoop if stringright ($var,4) = ".bak" Then $slen = StringLen ($var) $new = stringleft ($var,$slen - 4) $copykey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & $new $destkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & $new & ".old" _RegMoveKey($copykey, $destkey) $movesourcekey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & $var $movedestkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & $new _RegMoveKey ($movesourcekey, $movedestkey) ; Parameters.....: $s_key - Source key ; $s_val - Source value ;RefCount set to 0 RegWrite ($movedestkey,"RefCount","REG_DWORD",0) CheckMenuItem() ; Write Log file Local $file = FileOpen("fixlog.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Get current system time $tCur = _Date_Time_GetSystemTime() FileWrite($file, _Date_Time_SystemTimeToDateTimeStr($tCur) & @CRLF) FileWrite($file, "Move From: " & $copykey & @CRLF) FileWrite($file, "Move To: " & $destkey & @CRLF) FileWrite($file, "Move From: " & $movesourcekey & @CRLF) FileWrite($file, "Move To: " & $movedestkey & @CRLF) FileWrite($file, "Changed RefCount Value to 0" & @CRLF) FileClose($file) MsgBox (0,"Completed","Press OK to Exit. Restart computer and login like normal.") Exit Else MsgBox (0,"Completed","Press OK to Exit. A bad profile was not found. Please contact the Help Desk for more troubleshooting ideas.") Exit EndIf Next

Read 10863 times Last modified on Sunday, 22 October 2017 17:38

Leave a comment

Because of spammers, I've changed the comments so they do not auto-show, but if you leave a comment, it should post within 24 hours.