string sqlString = "net use \\\\10.30.35.59\\ipc$ \"234.\" /user:\"asd\"";
共享登陆(sqlString);
private static void 共享登陆(string sqlString)
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", "/c " + sqlString);
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
if (!output.Contains("命令成功完成"))
{
MessageBox.Show("共享访问失败");
}
}