Files
OfficeTool/Services/OdtDownloader.cs
hariel1985 4937ac4b1c 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>
2026-03-31 05:40:50 +02:00

97 sor
3.4 KiB
C#

using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace InstaSoftOfficeTool.Services
{
public class OdtDownloader
{
private const string OdtDownloadUrl = "https://go.microsoft.com/fwlink/p/?LinkID=626065";
public event Action<string> StatusChanged;
public event Action<int> ProgressChanged;
public string OdtFolder { get; private set; }
public string SetupExePath { get; private set; }
public OdtDownloader()
{
OdtFolder = Path.Combine(Path.GetTempPath(), "InstaSoftODT");
}
public async Task<bool> DownloadAndExtractAsync()
{
try
{
Directory.CreateDirectory(OdtFolder);
var odtExePath = Path.Combine(OdtFolder, "officedeploymenttool.exe");
SetupExePath = Path.Combine(OdtFolder, "setup.exe");
if (File.Exists(SetupExePath))
{
StatusChanged?.Invoke("Az ODT setup.exe m\u00e1r el\u00e9rhet\u0151, let\u00f6lt\u00e9s kihagyva.");
return true;
}
StatusChanged?.Invoke("Office Deployment Tool let\u00f6lt\u00e9se...");
using (var client = new WebClient())
{
client.DownloadProgressChanged += (s, e) =>
{
ProgressChanged?.Invoke(e.ProgressPercentage);
};
await client.DownloadFileTaskAsync(new Uri(OdtDownloadUrl), odtExePath);
}
StatusChanged?.Invoke("ODT kicsomagol\u00e1sa...");
var runner = new ProcessRunner();
var exitCode = await runner.RunAsync(odtExePath,
"/extract:\"" + OdtFolder + "\" /quiet");
if (exitCode != 0)
{
StatusChanged?.Invoke("Hiba: Az ODT kicsomagol\u00e1sa sikertelen (k\u00f3d: " + exitCode + ")");
return false;
}
if (!File.Exists(SetupExePath))
{
StatusChanged?.Invoke("Hiba: A setup.exe nem tal\u00e1lhat\u00f3 a kicsomagol\u00e1s ut\u00e1n.");
return false;
}
StatusChanged?.Invoke("ODT sikeresen let\u00f6ltve \u00e9s kicsomagolva.");
return true;
}
catch (Exception ex)
{
StatusChanged?.Invoke("Hiba a let\u00f6lt\u00e9s sor\u00e1n: " + ex.Message);
return false;
}
}
public async Task<int> RunSetupAsync(string configXmlPath, Action<string> outputCallback)
{
var runner = new ProcessRunner();
runner.OutputReceived += line => outputCallback?.Invoke(line);
StatusChanged?.Invoke("Office telep\u00edt\u00e9s ind\u00edt\u00e1sa...");
return await runner.RunAsync(SetupExePath, "/configure \"" + configXmlPath + "\"");
}
public async Task<int> RunRemoveAsync(string configXmlPath, Action<string> outputCallback)
{
var runner = new ProcessRunner();
runner.OutputReceived += line => outputCallback?.Invoke(line);
StatusChanged?.Invoke("Office elt\u00e1vol\u00edt\u00e1s ind\u00edt\u00e1sa...");
return await runner.RunAsync(SetupExePath, "/configure \"" + configXmlPath + "\"");
}
}
}