共享登陆

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("共享访问失败");
     }
}

posted @ 2024-08-21 09:10  网络来者  阅读(10)  评论(0)    收藏  举报