Running process on remote server

  • Thread starter Thread starter Alexander Kushner
  • Start date Start date
A

Alexander Kushner

Guest
protected void btnSave_Click(object sender, EventArgs e)
{
int intDummy;
Process p = new Process();

try
{
//p.StartInfo.FileName = @"\\ITVeritonSales1" +
// "\\c:\\programs\\valueaddedc\\GenericDashboard.bat " + this.ddlProduct.SelectedValue + " "
// + this.ddlProduct.SelectedItem.Text + "";
//p.StartInfo.Arguments = @"\\ibi20-pc -u ibi20 -p 12345 -i c:\windows\system32\notepad.exe";
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c c:\\pstools\\psexec \\\\ITVeritonSales1 -u evansdist\administrator -p xxx -d -i c:\\windows\\system32\\notepad.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.RedirectStandardError = true;
//Response.Redirect("GenericDashboard.aspx?ProductID=" + ddlProduct.SelectedValue + "&Product=" + ddlProduct.SelectedItem.Text + "&NightShift=" + chkNightShift.Checked
// + "&MinsAndSecs=" + ddlMinsAndSecs.SelectedValue);
//Debug.WriteLine(p.StartInfo.FileName + " " + p.StartInfo.Arguments);
//Debug.Assert(1 == 0);
p.Start();
p.WaitForExit(30000);

if (!p.HasExited)
p.Kill();
}
catch (Exception ex)
{
intDummy = 0;
}
finally
{
p.Dispose();
}
}

Before p.Kill(), I get system invalidoperationexception. Before p.Dispose(), "Only part of a readprocessmemory or writeprocessmemory request was completed." I can get this to work by using psexec in cmd but why not in C#?

Continue reading...
 
Back
Top