每隔一段时间,我运行cmd作为我的pipe理员用户。 为了方便起见,我设置了一个快捷方式
C:\Windows\System32\runas.exe /u:admin.user@domain cmd
在某些时候,我想运行指向我的普通用户的映射驱动器的脚本。
C:\Windows\system32>net use Status Local Remote Network ------------------------------------------------------------------------------- Unavailable L: \\fileserver\shared\path Microsoft Windows Network Unavailable X: \\fileserver\shared\temp Microsoft Windows Network The command completed successfully.
我特别想让我的L:驱动器映射。 我觉得像这样的东西应该工作…
C:\Windows\system32>net use l: Local name l: Remote name \\fileserver\shared\path Resource type Disk The command completed successfully. C:\Windows\system32>l: The system cannot find the drive specified.
如果我重新映射驱动器,一切都是开心的,但它是一件苦差事(现实中的“path”更长)。
C:\Windows\system32>net use l: \\fileserver\shared\path The command completed successfully. C:\Windows\system32>l: L:\>
正如这篇Technet文章所述, 这是UAC的一个副作用。 可以通过向名为EnableLinkedConnections的registry项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System添加一个条目,键入DWORD和值1来避免这种情况。 这将使在常规用户凭证下创build的networking连接可用于通过RunAs以提升特权运行的进程。
由于pipe理员帐户在Vista和Windows 7中的工作方式而出现问题。当您使用pipe理员帐户login时,帐户将获得两个令牌,一个标准用户令牌和一个pipe理员令牌。 当您最初映射驱动器时,使用标准用户令牌。 在提升的命令提示符下使用pipe理员令牌。 映射的驱动器在pipe理员令牌的上下文之外。 我希望这是有道理的。 最好的解决方法是使用UNC驱动器path或在提升的命令提示符下重新映射驱动器。 这是另一个解决方法。 请注意,这是不build议的。 我没有在Windows 7中testing过。这篇文章是关于Vista的。