The tskill command when used via C # (Visual Studio) returns this error:
'tskill' not recognized as an internal or external command, operable program or batch file
However the same command when running via the command prompt works without any problem. I figured maybe this could happen through Visual Studio using its own directory to enable access to the Windows command lines, so I set up another working directory to it, as can be seen. However, still unsuccessful.
I checked that this question has already been done, though the answer does not serves.
private void ClosePorts(object sender, EventArgs e)
{
var processStartInfo = new ProcessStartInfo();
processStartInfo.WorkingDirectory = (@"C:\Windows\System32\");
processStartInfo.FileName = ("cmd.exe");
processStartInfo.Arguments = string.Format("/c {0}", string.Concat(@"tskill com2tcp"));
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;
processStartInfo.LoadUserProfile = true;
processStartInfo.Verb = @"runas";
processStartInfo.CreateNoWindow = true;
Process proc = Process.Start(processStartInfo);
Console.WriteLine(proc.StandardOutput.ReadToEnd());
}
Thanks for any help.