110,534
社区成员
发帖
与我相关
我的任务
分享
explorer \\192.168.40.38
public string ConnectLan(string p_Path, string p_UserName, string p_PassWord)
{
System.Diagnostics.Process _Process = new System.Diagnostics.Process();
_Process.StartInfo.FileName = "cmd.exe";
_Process.StartInfo.UseShellExecute = false;
_Process.StartInfo.RedirectStandardInput = true;
_Process.StartInfo.RedirectStandardOutput = true;
_Process.StartInfo.CreateNoWindow = true;
_Process.Start();
//NET USE \\192.168.0.1 PASSWORD /USER:UserName
_Process.StandardInput.WriteLine("net use " + p_Path + " " + p_PassWord + " /user:" + p_UserName);
_Process.StandardInput.WriteLine("exit");
_Process.WaitForExit();
string _ReturnText = _Process.StandardOutput.ReadToEnd();// 得到cmd.exe的输出
_Process.Close();
return _ReturnText;
}