How can I create a login script that will delete the contents of the folder below, each time a user logs off of a PC? (We have a shared PC that about a dozen users use, for a particular program. That program caches their AD login credentials in the directory below, which often creates problems when their AD password is reset. The solution is to clear the folder contents each time the users logs off of the PC).
C:\Documents and Settings\%username%\Application Data\Identities*.*
So, I've tried to create a script using the 'del' command with the /q switch. But, testing it with a manual execution first from the command prompt, it never works, says the directory cannot be found.
C:\del /q C:\Documents and Settings\%username%\Application Data\Identities*.*
Use powershell and create a logoff script (best applied through gpo) that's gets the user's profile path from
HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\<User SID>\ProfilePath
and then delete that folder. That will keep you compatible from XP to 8.You can look at the owner of the
explorer.exe
process from powershell to find the locally logged on user at the time. An example of course:Remove the c:\ from the command and put it in quotes
The program doesn't have a setting to choose not to cache? What about if you delete or rename that folder or restrict write access to it? Any how. to simplify your script, try:
del /q /s "%appdata%\Identities\*.*"