2

We're finally getting around to moving our software's documents out of the program's own directory and into "My Documents". We're also adding a "requestedPrivileges" line to the manifest to prevent further trouble with virtualization.

However if we only did that then anyone who had been running the old versions in Vista/7 is likely to lose their work somewhere within the hidden VirtualStore directory after updating. So what's the preferred way of migrating into the 21st century?

Frankly I'm a little wary of copying files around, especially as I can't seem to find a programmatic way of getting at the shadow directory, but presumably plenty of other people must have had the same problem before us.

doynax
  • 4,285
  • 3
  • 23
  • 19

1 Answers1

2

Don't add requestedPrivileges unless you legitimately need administrative rights in order for your program to work - nothing in your description suggests that you do. That should also let you simply copy the files on the first boot as if they were still in your program directory, because any virtualization would still be in effect.

However, if you absolutely must do the migration without UAC enabled, you can find your files in %LOCALAPPDATA%\VirtualStore\path\to\file. For example, if your file would have been stored in C:\Program Files\OurApp\, you'll find it in %LOCALAPPDATA%\VirtualStore\Program Files\OurApp\.

To get the path to %LOCALAPPDATA%, you can use SHGetSpecialFolderPath with CSIDL_LOCAL_APPDATA as the CSIDL parameter.

Michael Madsen
  • 54,231
  • 8
  • 72
  • 83
  • No, we don't need any additional privileges so we're using the asInvoked level. It's just that we've had a some problems with virtualization (such as users backing up old data via Explorer) and would like to avoid them in the future. That's is why we're moving things after all. I suppose a stub executable to do the copying should do the trick as well though. – doynax Mar 15 '11 at 16:09
  • @doynax: By requiring more privileges, you will only annoy the users who leave UAC on and now have to accept giving your program administrative rights every time they launch the program - and that's just the users with the Administrator role on the machine; for users who normally run under a limited account, they'll have to enter the administrator password every time. At best, adding the privileges would be a workaround, not a fix; to fix the issue, you'll have to move everything, and once you do, you don't need the privileges. – Michael Madsen Mar 15 '11 at 16:21
  • I'm requesting the "asInvoked" level, which according to MSDN is the proper way to signal that your application is Vista-aware (and thus to shut off virtualization) without asking for any extra privileges. – doynax Mar 15 '11 at 16:52
  • @doynax: Ah, yes, my mistake - I just noticed that I misread that. As long as you're using asInvoker, that's fine, and it will indeed shut off that virtualization. – Michael Madsen Mar 15 '11 at 17:06