Vista Program Files Hide and Seek
Sep 14th, 2007 by Chris Thornton
I’m writing this off-topic post in hopes that it’ll save other folks the time/trouble that I just wasted trying to troubleshoot an installer that seemed to be installing old versions of files. Nothing was wrong with the installer, nothing was wrong with my eyes, nothing was wrong at all, except my memory. As a software developer, I had already learned about this pitfall, and just plain forgot.
Vista Pain In The Neck Rule #1: If you modify or create a program in the “program files” directory, or a program does it for you, Vista will play tricks on you.
This includes:
- Editing a file yourself, even if you have administrator privleges
- Any program that writes a data file to the program files directory (unless it’s an installer).
- Any program that writes configuration or .ini files to the program files directory (unless that program was launched by an installer).
Here’s what I did:
I had modified a file myself, using TextPad or EmEdit (both are excellent text editors), in c:\program files\ClipMate7\Languages. The file was called “english.lng”. This was to test some changes for an upcoming maintenance release. The modified file contained a version string 7.2.05.165, so I could easily check it within the program, to see if the translation was up-to-date.
A few days later (today), I installed my shiny new version 7.2.06.166. Guess what? English.lng contained the 7.2.05.165 version. 🙁
I re-checked the installer and build scripts and directories. Everything was fine. As far as I could see, 7.2.06.166 was making it into the installer. I uninstalled, rebooted, re-installed, and still had the old file.
Then I remembered the whole UAC thing, and how Vista makes some sort of “shadow” copy. That’s what happens when Vista asks for special permission to continue with the “file save” or delete. Yes, yes, yes indeed. I found the old file lurking in:
C:\Users\Chris\AppData\Local\VirtualStore\Program Files\ClipMate7\Language\English.lng
I deleted it, and everything was fine.
How did this happen?
I was assuming that the installer would be able to clean up any such problems, but apparently, while the special UAC privlege for installers only allows them to install/delete files in the program files directory, it does NOT have provisions for reconciling newly-installed files with older files that are lurking in the VirtualStore directory. Even though the installer supplied a new version of english.lng, Vista showed me the old one.
Lessons Learned To Date:
- If a program file needs to write important data to its own directory, install it somewhere else. I have set up D:\Apps, for this purpose.
- If you are backing up a program that seems to store its data in its own directory, and you didn’t follow #1 above, don’t count on the backup actually having the right files.
- If you install a program and it offers to “run program now”? Don’t. Just let the installer quit, and then run the program yourself. Otherwise you’ll run the risk of the program running with elevated privleges, and creating data and configuration files that cannot be updated later.
- And today’s lesson: If you edit anything in the Program Files directory, you’re asking for trouble. Be sure to check the VirtualStore cache and use cloud solutions to avoid problems like this in the future.
- The Virtual Store resides in: C:\Users\<userid>\AppData\Local\VirtualStore\Program Files\ClipMate7\Language\English.lng
References and helpful links:
- Vista and User Virtualization
- What is UAC? (And how to turn off those annoying prompts!)
Thank you for the tips. I’m still an XP holdout, hoping it was really just another ‘in between’ OS like Millennium was. But it is really looking like Vista is Microsoft’s best effort, for now(?), so this kind of information is indeed going to come in handy for many. Thanks to Chris over at Clipmate.com for sharing this info about Vista and the way it handles files in the Program Files directory.
That’s interesting. Wasn’t aware of that. Got to say that I find some of Vista’s new folder structure to be quite confusing. Bit of a mess sometimes…
This is the single most useful answer to a problem i have been having with Vista. Thanks!
Thank you very much for sharing this information
Thank you for the information. It is too bad I didn’t read it before installing my application to the program files directory on a new vista computer. took me hours to find my database.
Windows 7 also does this. Unfortunatley I did not see this post till after I had spend a fair while attempting to see where I thought I’d gone wrong.
At least I understand what is happening now. Thank you!