为什么文件被放置在“C:\Users\<用户名>AppData\Local\VirtualStore\Program Files(x86)”中?用户名>
我最近更新了我的 Visual Basic 6.0 应用程序,现在包含一个 exe.manifest 文件以防止 < a href="http://en.wikipedia.org/wiki/User_Account_Control" rel="noreferrer">UAC 虚拟化。应用此更新后,某些用户无法找到其数据文件(访问 MDB 文件)以及之后系统搜索,他们最终在 C:\Users\
中找到它。
该文件夹区域的用途是什么?文件如何/何时移动到该区域?我们如何预防呢?我现在希望我的应用程序使用 .manifest
这不会再发生。当应用程序被放置在 UAC 虚拟化中时,文件是否在使用清单之前放置在那里?
I recently updated my Visual Basic 6.0 application and now include an exe.manifest file to prevent UAC Virtualization. After applying this update, some users can't find their data files (Access MDB files) and after a system search they end up finding it in C:\Users\<username>AppData\Local\VirtualStore\Program Files(x86)
.
What is this folder area for and how/when do files get moved to this area? How do we prevent it? I'm hoping now that my application uses a .manifest
this won't happen again. Did the files get placed there before the manifest was used as the application was being placed in UAC Virtualization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未以提升权限运行的应用程序不应访问
Program Files
和Program Files (x86)
目录。这对于安全来说是有好处的。此外,在大多数情况,当开发人员告诉他的程序将数据保存在Program Files
文件夹中时,例如程序设置,他完全忘记了程序设置应该是每个用户的事情!也就是说,本地计算机上的每个用户都应该能够使用该程序而不影响其他用户。换句话说,一个行为良好的应用程序应该将其设置保存在该目录中。
例如,我的 AlgoSim 软件写入
当然,
必须在运行时动态查找路径。用于
此。
自 Windows Vista 以来,未以提升权限运行的应用程序尝试写入
Program Files
(或Program Files (x86)
)文件夹实际上会写入VirtualStore文件夹,不知不觉中。微软认为这比程序失败(由访问限制引起)要好。事实上,由于这一点,大多数将设置保存在 Program Files 文件夹中的旧程序将继续在 Windows Vista+ 上运行,并且每个用户都将获得自己的设置,作为奖励,即使原来的软件厂商没有想到这一点。您可以使用清单告诉 Windows 您的应用程序知道 VirtualStore 并且 Windows 不应在运行时更改任何路径。但是,如果您确实希望能够写入
Program Files
文件夹,那么我认为您必须每次都以提升的权限运行应用程序,这通常是不可取的。有关如何创建清单以使程序在每次执行时显示 UAC 提示以及如何禁用 VirtualStore 的详细信息,已在之前的几个堆栈溢出问题中得到解决。请随意使用搜索框!
An application that is not running with raised privileges should does not have access to the
Program Files
andProgram Files (x86)
directories. This is good for safety. In addition, in most cases when a developer tells his program to save data in theProgram Files
folder, for example, program settings, he has completely forgotten that program settings should be a per-user thing! That is, every user on the local computer should be able to use the program without affecting the other users. In other words, a well-behaved application should instead save its settings in thedirectory.
For instance, my AlgoSim software writes to
Of course, the
path must be looked-up dynamically at runtime. Use
for this.
Ever since Windows Vista, applications that are not running with raised privileges that try to write to the
Program Files
(orProgram Files (x86)
) folder will in fact write to the VirtualStore folder, unknowingly. Microsoft thought that this would be better than a program failure (caused by the access restriction). And indeed, thanks to this, most old programs that save their settings in theProgram Files
folder will continue to work with Windows Vista+, and each user will get her own settings, as a bonus, even though the original software manufacturer did not think of this.You can use a manifest to tell Windows that your application is aware of VirtualStore and that Windows should not change any paths during runtime. But if you really want to be able to write to the
Program Files
folder, then I think that you have to run the application with raised privileges, every time, which is inadvisable in general.The details on how to create manifests to make your program display the UAC prompt on each execution, and how to disable VirtualStore, have been addressed at several previous Stack Overflow questions. Feel free to use the search box!
我的猜测是,您的清单显示为 asInvoker,并且您的应用程序尝试写入程序文件。当用户在没有清单的情况下运行它时,它会写入程序文件的虚拟存储,这是他们后来找到一些文件的路径。当他们使用清单运行时,它根本无法写入(访问被拒绝),但是您的应用程序向他们隐藏了错误,或者他们不理解该错误,因此他们没有向您提及。
短期修复 - 使用 requireAdministrator 清单。这会激怒用户,但写入会成功。长期修复 - 不要写入 ProgramFiles。有更好的每用户选项,例如 AppData。
My guess is that your manifest says asInvoker, and that your app tries to write to Program Files. When the users ran it without a manifest, it wrote to the virtual store for Program Files, which is the path where they found some files later. When they ran with a manifest, it failed to write at all (with access denied) but either your application hid the error from them, or they didn't understand the error so they didn't mention it to you.
Short term fix - use a requireAdministrator manifest. This will irritate the users but the writes will succeed. Longer term fix - don't write to ProgramFiles. There are better per-user options, like AppData.