共享登陸

网络来者發表於2024-08-21

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("共享訪問失敗");
}
}

相關文章