3
The tskill command when used via C# (Visual Studio) returns this error:
'tskill' not recognized as an internal or external command, a operable program or a batch file
However the same command when executing via command prompt works without any problem. I thought that maybe this could happen by Visual Studio using a directory to enable access to the Windows command lines, so I set up another working directory to it, as can be seen. Tedious, yet unsuccessful.
I found that that question has already been made, but the answer does not suit me.
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());
}
I appreciate any help.
why not execute the command with the full path?
"C:\Windows\System32\tskill com2tcp"
– Ricardo Pontual
The same way it doesn’t work, I’ve tested it this way.
– Caio de Paula Silva