我在这里和那里看到了几个例子,这就是我想要实现的目标。我知道以下内容不起作用,但基本上我正在尝试从远程机器上提取 %logonserver% 。出于某种原因,wmi 查询不返回任何数据。
try
{
System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo("\\\\"+txtboxMachineName.Text+"\\c$\\Windows\\System32\\cmd.exe", "/c echo %logonserver%");
startinfo.RedirectStandardOutput = true;
startinfo.UseShellExecute = false;
startinfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new Process();
proc.StartInfo = startinfo;
proc.Start();
lblLogonServer.Text = proc.StandardOutput.ReadToEnd();
}
catch
{
lblLogonServer.Text = "Error has been encountered obtaining Logon Server";
}