Initial release v1.01 — InstaSoft Office Tool
Office deployment wizard for InstaSoft customers: - Install Office 2019/2021/2024 (Standard, Professional Plus, Home & Business) - Auto-download ODT from Microsoft, generate config XML, run setup - Remove existing Office installations (C2R + MSI) - License troubleshooting via ospp.vbs (dstatus, unpkey) - Fluent Design UI (WPF .NET Framework 4.8, Win7+ compatible) - Hungarian interface, multi-language Office installation - Product key input with auto-activation support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
63
Services/ProcessRunner.cs
Normal file
63
Services/ProcessRunner.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InstaSoftOfficeTool.Services
|
||||
{
|
||||
public class ProcessRunner
|
||||
{
|
||||
public event Action<string> OutputReceived;
|
||||
|
||||
public async Task<int> RunAsync(string fileName, string arguments, bool redirectOutput = true)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = arguments,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = redirectOutput,
|
||||
RedirectStandardError = redirectOutput,
|
||||
StandardOutputEncoding = redirectOutput ? Encoding.UTF8 : null,
|
||||
StandardErrorEncoding = redirectOutput ? Encoding.UTF8 : null
|
||||
};
|
||||
|
||||
using (var process = new Process { StartInfo = psi })
|
||||
{
|
||||
if (redirectOutput)
|
||||
{
|
||||
process.OutputDataReceived += (s, e) =>
|
||||
{
|
||||
if (e.Data != null)
|
||||
OutputReceived?.Invoke(e.Data);
|
||||
};
|
||||
process.ErrorDataReceived += (s, e) =>
|
||||
{
|
||||
if (e.Data != null)
|
||||
OutputReceived?.Invoke("[HIBA] " + e.Data);
|
||||
};
|
||||
}
|
||||
|
||||
process.Start();
|
||||
|
||||
if (redirectOutput)
|
||||
{
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
}
|
||||
|
||||
await Task.Run(() => process.WaitForExit());
|
||||
return process.ExitCode;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> RunAndCaptureAsync(string fileName, string arguments)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
OutputReceived += line => sb.AppendLine(line);
|
||||
await RunAsync(fileName, arguments);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user