I´m trying to make a program. that will find a programs PID number. so far i got it to work with notepad.
Code:
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/C for /f \"tokens=1,2\" %a in " + "('Tasklist /fi \"imagename eq notepad.exe\" /nh') do @echo %b",
RedirectStandardOutput = true,
UseShellExecute = false,
}
};
Its not going to be a Notepad it was just for testing purposes. I want it to be a string that stands there instead of notepad.
Like this
String myProgram = @"[insert program name]";
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/C for /f \"tokens=1,2\" %a in " + "('Tasklist /fi \"imagename eq MyProgram\" /nh') do @echo %b",
RedirectStandardOutput = true,
UseShellExecute = false,
}
};
I don't know how to change it from the text "notepad" to my string.