c++ - Vista 中提升的进程不会覆盖文件

标签 c++ windows uac

我正在尝试从另一个主机进程运行提升的进程,例如 file_copier.exe,在 Vista 上使用 ShellExecuteEx 和 lpVerb = "runas"。它显示 UAC 对话框并以提升的方式运行,并将文件复制到“危险”文件夹,但它不会覆盖现有文件(exe)。

我在这里读过:http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx UAC 实际上不会覆盖现有文件,而是将新文件存储在某种缓存中。但我无法弄清楚(如果是这样的话)如何让它实际覆盖现有文件。感谢您的帮助。

最佳答案

你说的是virtualization of file system .要告诉 Windows 您的程序知道 Windows 规则,您应该更改您的 manifest file .

将以下文本添加到 list 中:

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!--The ID below indicates application support for Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
    </application>
  </compatibility>

关于c++ - Vista 中提升的进程不会覆盖文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1378520/

相关文章:

c++ - 如何创建具有任意数量(编译时确定)容器的内存池?

用于制作 GUI 的 C++ 库

delphi - 不捕获 list 文件

c# - C# 应用程序中的管理员权限提示弹出窗口

c++ - 将int转换为float?

c++ - 删除C++ vector 中的字段

c++ - 具有类型特征的通用 lambda

c++ - 在另一台计算机上启动使用 MinGW 编译的 Windows 应用程序时出现库链接错误

c - 需要有关 PVoid 的帮助

c++ - 如何从 Vista 和 Windows 7 上的应用程序启动屏幕键盘