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:
hariel1985
2026-03-31 05:40:50 +02:00
commit 4937ac4b1c
38 fájl változott, egészen pontosan 2496 új sor hozzáadva és 0 régi sor törölve

119
Services/LicenseManager.cs Normal file
Fájl megtekintése

@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace InstaSoftOfficeTool.Services
{
public class LicenseManager
{
public string OsppPath { get; private set; }
public bool FindOspp()
{
var searchPaths = new[]
{
// Click-to-Run (leggyakoribb — Office 365, 2019, 2021, 2024)
@"C:\Program Files\Microsoft Office\root\Office16\OSPP.VBS",
@"C:\Program Files (x86)\Microsoft Office\root\Office16\OSPP.VBS",
// Hagyományos MSI
@"C:\Program Files\Microsoft Office\Office16\ospp.vbs",
@"C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs",
@"C:\Program Files\Microsoft Office\Office15\ospp.vbs",
@"C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs",
@"C:\Program Files\Microsoft Office\Office14\ospp.vbs",
@"C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs",
};
foreach (var path in searchPaths)
{
if (File.Exists(path))
{
OsppPath = path;
return true;
}
}
try
{
var c2rPath = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Microsoft\Office\ClickToRun\Configuration")
?.GetValue("InstallationPath") as string;
if (!string.IsNullOrEmpty(c2rPath))
{
// C2R: root\Office16 vagy sima Office16
var candidates = new[]
{
Path.Combine(c2rPath, "root", "Office16", "OSPP.VBS"),
Path.Combine(c2rPath, "Office16", "OSPP.VBS"),
};
foreach (var candidate in candidates)
{
if (File.Exists(candidate))
{
OsppPath = candidate;
return true;
}
}
}
}
catch { }
return false;
}
public async Task<string> GetStatusAsync()
{
if (string.IsNullOrEmpty(OsppPath))
return "Az ospp.vbs nem tal\u00e1lhat\u00f3.";
var runner = new ProcessRunner();
return await runner.RunAndCaptureAsync("cscript",
"//Nologo \"" + OsppPath + "\" /dstatus");
}
public List<string> ParseLicenseKeys(string dstatusOutput)
{
var keys = new List<string>();
var regex = new Regex(@"Last 5 characters of installed product key:\s*(\S+)",
RegexOptions.IgnoreCase);
foreach (Match match in regex.Matches(dstatusOutput))
{
keys.Add(match.Groups[1].Value);
}
return keys;
}
public async Task<string> RemoveKeyAsync(string last5Chars)
{
if (string.IsNullOrEmpty(OsppPath))
return "Az ospp.vbs nem tal\u00e1lhat\u00f3.";
var runner = new ProcessRunner();
return await runner.RunAndCaptureAsync("cscript",
"//Nologo \"" + OsppPath + "\" /unpkey:" + last5Chars);
}
public async Task<string> RemoveAllKeysAsync()
{
var status = await GetStatusAsync();
var keys = ParseLicenseKeys(status);
if (keys.Count == 0)
return "Nem tal\u00e1lhat\u00f3 telep\u00edtett term\u00e9kkulcs.";
var results = new List<string>();
foreach (var key in keys)
{
var result = await RemoveKeyAsync(key);
results.Add(key + ": " + result.Trim());
}
return string.Join("\n", results);
}
}
}