I have a problem with remotely starting a proccess with psexec.exe. My solution looks like this, I have on server a cmd script, that runs my console application. The applications job is to start a test run with vstest.console.exe with the help of following code:
var config = LoadConfigFromFile<DeploymentStorage>(configFile);
var currentDateTime = DateTime.Now;
var resultFileName = String.Format("testresults{0}{1}{2}{3}{4}{5}.trx",
currentDateTime.Year, currentDateTime.Month, currentDateTime.Day, currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second);
ProcessStartInfo processInfo =
new ProcessStartInfo(config.TestSettings.First(x => x.Key == "MSTestLocation").Value,
"\"" + config.TestSettings.First(x => x.Key == "TestContainer").Value + "\" /logger:trx;LogFileName=\"" +
config.TestSettings.First(x => x.Key == "TestResultLocation").Value + resultFileName + "\"");
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
var process = Process.Start(processInfo);
process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
Console.WriteLine("output>>" + e.Data);
process.BeginOutputReadLine();
process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>
Console.WriteLine("error>>" + e.Data);
process.BeginErrorReadLine();
process.WaitForExit();
var exitCode = process.ExitCode;
Console.WriteLine("ExitCode: {0}", exitCode);
process.Close();
If I run this script localy on the server everything works fine, the test run starts. But if I start this script remotely through my local computer with the help of psexec.exe I get the following error:
Failed to queue test run '[Servername] 2018-04-24 15:17:20': Unable to start the agent process.
It's not the problem of psexec.exe, with this tool I can run other programs and cmd scripts, I can directly run the vstest.console.exe with it too, but I need to run the tests through my console app.
Why psexec.exe is not running my app? Do I miss something in the configuration of the process?
EDIT: I run psexec.exe with the following command on my local computer:
C:\Programs\PSTools\psexec.exe \\my-server -h C:\TestApp\MyTestTool.exe TEST C:\TestApp\base.config.xml
Where TEST and path to base.config.xml are arguments passed to the console app.
EDIT2: Well, it seems, that I have misinterpreted my problem. I run psexec.exe command from command line on my local computer. It should run my console app called TestApp at the server. This console app on the server should start vstest.console.exe with the help of the code above, not the psexec.exe and it can't do it. Hope that this makes it a litle clearer.
EDIT3: Ok, I know now what is cousing the problem, I can not run tests remotely, if my test container is a *.orderedtest file. If I try to run test setting a dll as test container, everything works fine.