Windows7 corrupted profile – prevention exists

user-profileswindows 7

I have dedicated Windows7 (not on domain) virtual machine for overnight automation testing. Some commands (mySQLdump, tscon.exe) must be run under administrator account.

Last week administrator account's profile was corrupted. I fixed it by renaming it in the registry and logging in as administrator. And today it is corrupted again.

I use administrator account only to run above commands via runas. Also the computer is restarted via cmd – shutdown command – quite often. Especially every night before automation testing starts.

I checked the comp for viruses – did full scan using avast although I believed that the comp is clean.

Any idea how to prevent the profile to get corrupted again?

update

So the first log entry in event log is today from 1.15am and one of my scripts ran runas command as administrator exactly at 1.15am. It was second time that runas war executed though after the testing started. The same happened second day in a row. Before the testing starts I need to copy one file that is locked. So I run handle.exe from runas to unlock it. That is what I think causing the profile to get corrupted. I am not able to reproduce it by myself.

The message from event viewer is

Windows cannot load the locally stored profile. Possible causes of this error include insufficient security rights or a corrupt local profile.

DETAIL – The process cannot access the file because it is being used by another process.

Best Answer

Corrupted profiles are kind of a common problem, but it's still a problem; One that's a symptom of a larger problem. It's "common", but not "normal".

On the other hand, based on the provided event log entry, your profile isn't corrupted, it just can't be loaded because during loading it's trying to access a file that's locked by another process (like it says). You have to determine what the file is, and why it's locked.

If you suspect it's your use of Handle.exe, maybe figure out another way to release the file you need to copy without abruptly closing handles, as that's highly unsafe. If you look at the usage info for Handle it even warns you "WARNING: Closing handles can cause application or system instability.". :)

Related Question