views:

1453

answers:

2

I have a legacy VB6 program which installs an Access file in a sub-directory of the common data folder (CSIDL_COMMON_APPDATA). I have now installed this program on a 64-bit Vista system, and the program works fine and accesses the file at C:\ProgramData\Wow\WowCat.mdb, but this file does not show in Windows Explorer.

I want to overwrite this database, with a later version, taken from my old PC, but using Explorer I can't see the file in C:\ProgramData\Wow\ (I am showing all hidden and system files). If I go ahead and copy the new WowCat.mdb anyway, the program still works with the old one.

Stepping the code in VB, it is definately opening the file at: C:\ProgramData\Wow\WowCat.mdb. Searching the C: drive only shows the new copy, so where is the one that the program is accessing?

+1  A: 

This is because of folder redirection in Windows Vista. If you do not normally have the rights to write something into the C:\Program Files-folder, Vista will silently redirect those writes into a "secret" folder inside your user directory. The file will still be visible for the user who created the file (and any programs running as that user), but it will not be visible for anyone else. So your program is probably running as a different user than Explorer is, and thus Explorer cannot see it.

See the following output from dir /aL on my Vista 64-bit machine:

C:\ProgramData>dir /aL
 Volume in drive C has no label.
 Volume Serial Number is 74DB-58F8

 Directory of C:\ProgramData

02.11.2006  16:41    <JUNCTION>     Application Data [C:\ProgramData]
02.11.2006  16:41    <JUNCTION>     Desktop [C:\Users\Public\Desktop]
02.11.2006  16:41    <JUNCTION>     Documents [C:\Users\Public\Documents]
02.11.2006  16:41    <JUNCTION>     Favorites [C:\Users\Public\Favorites]
02.11.2006  16:41    <JUNCTION>     Start Menu [C:\ProgramData\Microsoft\Windows\Start Menu]
02.11.2006  16:41    <JUNCTION>     Templates [C:\ProgramData\Microsoft\Windows\Templates]
               0 File(s)              0 bytes
               6 Dir(s)  62 040 051 712 bytes free

The feature is known as reparse points or junctions, depending on where you read about them. They are very similar to symbolic links in Unix.

Vegard Larsen
A: 

Doing this properly requires a Windows Installer MSI or legacy installer running elevated the creates a subfolder under CommonAppDataFolder, gives Full Control for Everyone (or an appropriate Group) to this folder, and finally places your MDB there. You can also create the folder, move the MDB file there, and set permissions on just the file.

It is also possible for the EXE itself to do this on first run if it is run elevated or detects the omission and spawns an elevated process to do the job. Standards dictate that this action should be initiated via a menu item or button with the UAC Shield icon displayed however, and not just popping up a UAC prompt.

It is all much easier via an MSI package though.

Bob