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:
131
Pages/RemovePage.xaml.cs
Normal file
131
Pages/RemovePage.xaml.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using InstaSoftOfficeTool.Models;
|
||||
using InstaSoftOfficeTool.Services;
|
||||
|
||||
namespace InstaSoftOfficeTool.Pages
|
||||
{
|
||||
public partial class RemovePage : Page
|
||||
{
|
||||
private readonly MainWindow _main;
|
||||
private List<InstalledOffice> _detected;
|
||||
|
||||
public RemovePage(MainWindow main)
|
||||
{
|
||||
InitializeComponent();
|
||||
_main = main;
|
||||
Loaded += (s, e) => DetectOffice();
|
||||
}
|
||||
|
||||
private void DetectOffice()
|
||||
{
|
||||
_detected = OfficeDetector.Detect();
|
||||
|
||||
OfficeListPanel.Children.Clear();
|
||||
|
||||
if (_detected.Count == 0)
|
||||
{
|
||||
NoOfficeText.Visibility = Visibility.Visible;
|
||||
LicenseCleanupPanel.Visibility = Visibility.Collapsed;
|
||||
BtnRemove.IsEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var office in _detected)
|
||||
{
|
||||
var cb = new CheckBox
|
||||
{
|
||||
Content = office.DisplayName + (string.IsNullOrEmpty(office.Version) ? "" : " (" + office.Version + ")"),
|
||||
IsChecked = true,
|
||||
Style = (Style)FindResource("FluentCheckBox"),
|
||||
Tag = office,
|
||||
Margin = new Thickness(0, 4, 0, 4),
|
||||
FontSize = 14
|
||||
};
|
||||
OfficeListPanel.Children.Add(cb);
|
||||
}
|
||||
}
|
||||
|
||||
private async void BtnRemove_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Biztosan el szeretn\u00e9 t\u00e1vol\u00edtani a kiv\u00e1lasztott Office telep\u00edt\u00e9seket?",
|
||||
"Meger\u0151s\u00edt\u00e9s", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
if (result != MessageBoxResult.Yes) return;
|
||||
|
||||
BtnRemove.IsEnabled = false;
|
||||
LogPanel.Visibility = Visibility.Visible;
|
||||
|
||||
bool hasC2R = false;
|
||||
foreach (UIElement child in OfficeListPanel.Children)
|
||||
{
|
||||
if (child is CheckBox cb && cb.IsChecked == true)
|
||||
{
|
||||
var office = (InstalledOffice)cb.Tag;
|
||||
if (office.IsClickToRun)
|
||||
{
|
||||
hasC2R = true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(office.ProductCode))
|
||||
{
|
||||
AppendLog("MSI elt\u00e1vol\u00edt\u00e1s: " + office.DisplayName);
|
||||
var runner = new ProcessRunner();
|
||||
runner.OutputReceived += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
||||
await runner.RunAsync("msiexec", "/x " + office.ProductCode + " /qb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasC2R)
|
||||
{
|
||||
AppendLog("Click-to-Run Office elt\u00e1vol\u00edt\u00e1sa ODT-vel...");
|
||||
|
||||
var downloader = new OdtDownloader();
|
||||
downloader.StatusChanged += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
||||
|
||||
bool ok = await downloader.DownloadAndExtractAsync();
|
||||
if (ok)
|
||||
{
|
||||
string removeXml = OdtXmlGenerator.GenerateRemoveAll();
|
||||
string xmlPath = Path.Combine(downloader.OdtFolder, "remove.xml");
|
||||
File.WriteAllText(xmlPath, removeXml);
|
||||
|
||||
int exitCode = await downloader.RunRemoveAsync(xmlPath,
|
||||
msg => Dispatcher.Invoke(() => AppendLog(msg)));
|
||||
|
||||
AppendLog(exitCode == 0
|
||||
? "Office sikeresen elt\u00e1vol\u00edtva."
|
||||
: "Elt\u00e1vol\u00edt\u00e1s befejez\u0151d\u00f6tt (k\u00f3d: " + exitCode + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (CbCleanLicense.IsChecked == true)
|
||||
{
|
||||
AppendLog("Licenc-adatb\u00e1zis tiszt\u00edt\u00e1sa...");
|
||||
var lm = new LicenseManager();
|
||||
if (lm.FindOspp())
|
||||
{
|
||||
var cleanResult = await lm.RemoveAllKeysAsync();
|
||||
AppendLog(cleanResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendLog("Az ospp.vbs nem tal\u00e1lhat\u00f3 \u2014 licenc-tiszt\u00edt\u00e1s kihagyva.");
|
||||
}
|
||||
}
|
||||
|
||||
AppendLog("K\u00e9sz.");
|
||||
_main.ShowCloseButton();
|
||||
}
|
||||
|
||||
private void AppendLog(string text)
|
||||
{
|
||||
LogText.Text += DateTime.Now.ToString("HH:mm:ss") + " " + text + "\n";
|
||||
LogText.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user