Добавил сервис для запуска процессов

This commit is contained in:
2026-07-02 14:18:17 +03:00
parent e0b13d510d
commit d5915ccf72
3 changed files with 35 additions and 0 deletions
@@ -0,0 +1,27 @@
using MonitorAgent.Core.Abstraction;
using System.Diagnostics;
namespace MonitorAgent.Application.Services;
public class ProcessStarterService : IProcessStarterService
{
public async Task<string> StartProcessAsync(
string fileName, string arguments, CancellationToken cancellationToken = default)
{
using var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
}
};
process.Start();
return await process.StandardOutput.ReadToEndAsync(cancellationToken);
}
}