I have the Following Code
log.Info("Starting jar");
System.Diagnostics.ProcessStartInfo si = new ProcessStartInfo(procName);
si.RedirectStandardOutput = true;
si.RedirectStandardError = true;
si.UseShellExecute = false;
si.CreateNoWindow = false;
si.WorkingDirectory = System.IO.Directory.GetParent(Application.ExecutablePath) + "\\" + Properties.Settings.Default.rootDirectory;
//start a new process for Client
Process process = new Process();
process.StartInfo = si;
process.Start();
String name = process.ProcessName;
javaClientProcessId = process.Handle;
int javaProcessID = process.Id;
by using this code I am getting cmd as process name where in taskManager it showing as java.exe. From code it give 5412 as process.id
and 1029 as process.Handle
where as 6424 is the process id of java.exe
Is there any other method from I can get same Process ID which is in the TaskManager
NOTE procName is the path to a Bat file in which it run a jar file.
EDITED
When I execute the following code it gives the error from process.Kill()
line.
if (process != null)
{
process.Kill();
process.Close();
process.Dispose();
}
Cannot process request because the process (6504) has exited