问题描述
在成功编译应用程序后,我使用 VS 中的构建后事件将可执行文件传输到网络驱动器.每次我开始我的项目时,它都会在我的用户凭据下打开,但它需要管理员权限才能按预期运行.所以VS问我是否要关闭VS并在管理员权限下重新启动它.之后,VS 丢失了我连接的网络驱动器,因为它在管理员下运行,而不是我自己的凭据.如果我以管理员权限进入命令提示符并键入Net Use"命令,则没有连接网络驱动器.映射丢失的驱动器后,VS 能够按预期进行编译.
After a successful compiled application, I transferred the executable to a network drive with the post-build event in VS. Every time I start my project, it is opened under my user credential but it needs administrators privilege to run like expected. So VS ask me if I want to close VS and restart it under admin privilege. After that, VS looses my connected network drives because it runs under administrator, not my own credential. If I go in command prompt with admin privilege and type "Net Use" command, there is no network drives attached. After mapping the missing drives, VS is able to compile like expected.
现在,我的问题是,当我以管理员权限进入命令提示符时,我的凭据是什么?如果我输入whoami",我会得到我自己的用户名,但这并不完全正确,因为没有像在没有管理员权限的命令提示符下那样映射网络驱动器.即使我的用户在本地管理员组...
Now, my question is, when I go to command prompt with admin privilege, what is my credential? If I type "whoami", I get my own user name but it is not totally true because there is no mapped network drives like under command prompt without admin privilege. Even if my user is under local administrators group...
推荐答案
我们可以在注册表中添加一个值来同步链接令牌之间的映射网络驱动器.这记录在 某些程序在 UAC 时无法访问网络位置在 TechNet 中启用:
We can add a value in the registry to synchronize mapped network drives between linked tokens. This is documented under Some Programs Cannot Access Network Locations When UAC Is Enabled in TechNet:
要解决此问题,请配置 EnableLinkedConnections 注册表值.
注册表项是
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
EnableLinkedConnections
值是一个 DWORD
设置为 1 以在链接令牌之间共享映射驱动器或设置为 0 以表示默认行为.
The EnableLinkedConnections
value is a DWORD
set to 1 to share mapped drives between linked tokens or to 0 for the default behaviour.
这篇关于在管理员权限下运行时的用户是谁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!