Archive: Can't remove folder out of $APPDATA


Can't remove folder out of $APPDATA
I have a program that installs a folder into the C:/Documents and Settings/USER NAME/Application Data folder in Windows XP and C:/Users/USER NAME/AppData/Roaming folder in Windows Vista.

When I uninstall the program, it does not remove the folders in these locations. What's interesting is that my uninstaller was able to remove these when I first ran my tests.

I even have the function enabled: RequestExecutionLevel admin

I also have:
RMDir /r "$APPDATA\My Program"
RMDir /r "$LOCALAPPDATA\My Program"

It doesn't remove these folders upon uninstall anymore in my Windows XP.

If anyone can give me a hand or give me advice, I'd certainly appreciate it. If you are interested, I would really pay you to help me out with this!!! Save me from agony.


I think I answered my own question just now. What I did was I put the command "SetShellVarContext current" before the RmDir. I hope this helps others. Let me know if I did it correct.

So now it looks like:
SetShellVarContext current
RMDir /r "$APPDATA\My Program"
RMDir /r "$LOCALAPPDATA\My Program"