【发布时间】:2015-06-08 19:36:20
【问题描述】:
如果当前用户有权访问 UNC 路径,则此方法有效。直接打开。
Process.Start("\\USERSHARE\VALUE\EMPLOYEES\")
但是,由于代码中的 SQL 权限,我必须以无权访问 UNC 路径的用户身份运行整个程序。
我在应用程序中创建了一个按钮,该按钮将在资源管理器窗口中打开 UNC 路径,但我不知道如何强制执行该操作。
我也尝试了以下方法:
Dim procStartInfo As New ProcessStartInfo
Dim procExecuting As New Process
With procStartInfo
.UseShellExecute = True
.FileName = "Notepad.exe"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
procExecuting = Process.Start(procStartInfo)
这有效并提示 UAC 打开“记事本”。
这对打开UNC路径不起作用:
Dim procStartInfo As New ProcessStartInfo
With procStartInfo
.UseShellExecute = True
.FileName = "\\USERSHARE\VALUE\EMPLOYEES\"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
Process.Start(procStartInfo)
我了解打开文件共享与将 .FileName 指向可执行文件不同。
我在尝试打开远程文件夹之前尝试让应用提示 UAC 时遇到问题。
【问题讨论】: