以另一个用户的身份在网络共享上启动一个exe文件 [英] Process.Start an exe file on an network share as another user
问题描述
我需要运行一个位于我域中网络驱动器上的exe文件.该驱动器已成功作为"M:\"连接到我的PC,但是我知道,在启动位于网络共享上的进程时,Process.Start(string,string ...)必须具有文件的URL路径.
I need to run an exe file that is located on an network drive in my domain. The drive is successfully attached to my PC as "M:\", but I know that Process.Start( string , string...) need to have URL paths to files when staring processes located on network share.
这是我的代码:
string user = "user";
string password = "Qwerty1";
string domain = "nwtraderds";
string open = "file://myshare\dir1\dir2\dir3\test.exe";
string PwString = password;
char[] PasswordChars = PwString.ToCharArray();
SecureString Password = new SecureString();
foreach (char c in PasswordChars)
Password.AppendChar(c);
System.Diagnostics.Process.Start(open, user, Password, domain);
有趣的是:
System.Diagnostics.Process.Start(open);
工作正常. 我的想法已经用完了,有人可以帮我吗?
Works fine. I have run out of ideas, could someone help me please?
推荐答案
,虽然已经安装了网络共享,但Windows不会接受其他用户从同一桌面访问它-您甚至可以自己尝试:只需安装它与user1一起安装,然后尝试在另一个用户(user2)仍被装载(同一台机器,相同的Windows资源管理器!)的情况下,第二次(并行)装载相同的共享.
while a network share is already mounted then Windows won't accept accessing it from the same desktop with a different user - you can even try that yourself: just mount it with user1 and then try to mount the same share a second time (in parallel) with a different user (user2) while it is still mounted (same machine, same windows explorer!).
更新:
此file://myshare\dir1\dir2\dir3\test.exe
无法正常工作!
您可以使用\\myserver\myshare\dir1\dir2\dir3\test.exe
(不确定是否可以使用!),也可以使用驱动器号M:\\dir1\dir2\dir3\test.exe
!
You either use \\myserver\myshare\dir1\dir2\dir3\test.exe
(not sure if this works!) OR you use the drive letter M:\\dir1\dir2\dir3\test.exe
!
这篇关于以另一个用户的身份在网络共享上启动一个exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!