Windows 7: Delprof replacement for deleting profiles

We have migrated from Windows XP to Windows 7 at a high school and have run into a problem. The computer lab machines can have upwards of 5-10 different people log into the machine each day. As time goes on, the local cache of user accounts fills up the small hard drives we have. We don't have money to upgrade so we need to find a way to delete the profiles monthly.

In the past we have used delprof from microsoft which worked great. The problem is that delprof doesn't work for windows 7. Does anyone have a way to delete a profile from a batch/powershell script? If you simple delete the files, you get an error the next time the user logs in.

Thanks in advance


wmic path win32_userprofile where special!=true delete or the VBScript/PowerShell equivalent with the necessary WMI calls. The special parameter is redundant, since it will fail to delete special profiles (default profile, NetworkService, LocalService, etc.). If you log output, it will cut down on noise.


With PowerShell, I believe this will work.

$profiles = gwmi -class win32_UserProfile -filter "loaded='false'"
foreach ($prof in $profiles)
{
$prof.psbase.Delete()
}

Haven't tested as don't have Windows 7 or Vista box to work with.