Vista ProgramData 文件夹中缺少文件
我有一个旧版 VB6 程序,它在公共数据文件夹 (CSIDL_COMMON_APPDATA) 的子目录中安装 Access 文件。 我现在已经在 64 位 Vista 系统上安装了这个程序,并且该程序工作正常并访问 C:\ProgramData\Wow\WowCat.mdb 中的文件,但该文件没有显示在 Windows 资源管理器中。
我想用从我的旧电脑上获取的更高版本覆盖此数据库,但使用资源管理器我看不到 C:\ProgramData\Wow\ 中的文件(我显示所有隐藏文件和系统文件)。 如果我继续复制新的 WowCat.mdb,该程序仍然可以与旧程序一起使用。
在 VB 中单步执行代码,肯定会打开文件:C:\ProgramData\Wow\WowCat.mdb。 搜索 C: 驱动器仅显示新副本,那么程序正在访问的副本在哪里呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为 Windows Vista 中的文件夹重定向。 如果您通常无权向 C:\Program Files 文件夹写入内容,Vista 会默默地将这些写入重定向到您的用户目录内的“秘密”文件夹中。 该文件对于创建该文件的用户(以及以该用户身份运行的任何程序)仍然可见,但对于其他任何人都不可见。 因此,您的程序可能以与资源管理器不同的用户身份运行,因此资源管理器无法看到它。
请参阅我的 Vista 64 位计算机上 dir /aL 的以下输出:
该功能称为重解析点或连接,具体取决于您在何处阅读有关它们的内容。 它们与 Unix 中的符号链接非常相似。
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:
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.
要正确执行此操作,需要运行提升的 Windows Installer MSI 或旧版安装程序,在 CommonAppDataFolder 下创建一个子文件夹,为每个人(或适当的组)提供对此文件夹的完全控制权,最后将您的 MDB 放在那里。 您还可以创建该文件夹,将 MDB 文件移至此处,然后仅对该文件设置权限。
如果 EXE 运行提升或检测到遗漏并生成提升的进程来完成这项工作,则 EXE 本身也有可能在第一次运行时执行此操作。 标准规定,此操作应通过显示 UAC Shield 图标的菜单项或按钮启动,而不仅仅是弹出 UAC 提示。
不过,通过 MSI 包,一切都变得更加容易。
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.