当前目录与 'requireAdministrator' 权限链接时作为 UNC?

Current Directory as UNC when linked with 'requireAdministrator' privileges?

我最近通过添加清单 level='requireAdministrator' 修改了一个应用程序。在本地映射的文件夹中,我从这个应用程序调用 System::Environment::CurrentDirectory。例如,我将 X:\ 驱动器映射到 C:\toto。现在我需要管理员权限,我总是获得作为 UNC 的路径。但我想像以前一样将它作为映射文件夹(我想得到 X:\ 而不是 \MyComputer\C\toto。)

此 "new" 行为会导致应用程序进一步出现错误。我想要旧的行为,但我不明白为什么当我更改请求的权限时它突然改变了。

请注意,我的 UAC 设置为 0(最低级别...)。另外,请注意 System::IO::Directory::GetCurrentDirectory() 给出相同的结果。我正在使用 Win7SP1.

有什么想法吗?谢谢!

这是设计使然:

When UAC is enabled, the system creates two logon sessions at user logon. Both logon sessions are linked to one another. One session represents the user during an elevated session, and the other session where you run under least user rights.

When drive mappings are created, the system creates symbolic link objects ("DosDevices") that associate the drive letters to the UNC paths. These objects are specific for a logon session and are not shared between logon sessions.

最终用户可以设置 EnableLinkedConnections 注册表值,但作为应用程序开发人员,您应该修复错误而不是更改系统配置。