[英]Process.Start an exe file on an network share as another user
我需要運行位於我的域中的網絡驅動器上的exe文件。 驅動器成功地以“M:\\”的形式連接到我的PC,但我知道Process.Start(字符串,字符串......)在啟動位於網絡共享上的進程時需要具有文件的URL路徑。
這是我的代碼:
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);
工作正常。 我的想法已經用完了,有人可以幫我嗎?
雖然已經安裝了網絡共享,但Windows不會接受使用不同用戶從同一桌面訪問它 - 您甚至可以自己嘗試:只需使用user1安裝它,然后嘗試再次安裝相同的共享(並行) )當一個不同的用戶(user2)仍然掛載時(同一台機器,同一個Windows資源管理器!)。
更新:
這個file://myshare\\dir1\\dir2\\dir3\\test.exe
不起作用!
您可以使用\\\\myserver\\myshare\\dir1\\dir2\\dir3\\test.exe
(不確定這是否有效!)或者您使用驅動器號M:\\\\dir1\\dir2\\dir3\\test.exe
!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.