EDN Admin
Well-known member
Using the same command from a command line gives me the information I want, but for some reason this code doesnt. It doesnt give me any errors , the string that supposed to contain the output is empty. Does anyone have any experience with this. I dont want to use WMI because the application will be used across many domains and some may not have RPC enabled. Im also using PsExec in another application to launch a exe remotely and that works fine. try
{
string compname = textBox1.Text;
string pstools = @"Cstoolspsexec.exe";
ProcessStartInfo psi = new ProcessStartInfo(pstools, @"\" + compname + " -s /accepteula -d -i cmd /c ver")
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
CreateNoWindow = true
};
Process process = Process.Start(psi);
StreamReader myStreamReader = process.StandardOutput;
process.WaitForExit();
string output = myStreamReader.ReadToEnd().Trim();
MessageBox.Show("Remote computer version: " + output, "Version Info");
}
catch (Exception c)
{
MessageBox.Show("Unable to determine operating system for host " + c,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
}
View the full article
{
string compname = textBox1.Text;
string pstools = @"Cstoolspsexec.exe";
ProcessStartInfo psi = new ProcessStartInfo(pstools, @"\" + compname + " -s /accepteula -d -i cmd /c ver")
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
CreateNoWindow = true
};
Process process = Process.Start(psi);
StreamReader myStreamReader = process.StandardOutput;
process.WaitForExit();
string output = myStreamReader.ReadToEnd().Trim();
MessageBox.Show("Remote computer version: " + output, "Version Info");
}
catch (Exception c)
{
MessageBox.Show("Unable to determine operating system for host " + c,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
}
View the full article