Using PsExec to determine remote computers Windows version.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
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 = @"C:pstoolspsexec.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
 
Back
Top