v1.09 — Fix ODT download, selective removal, Display Level Full
- Direct CDN download (officecdn.microsoft.com/pr/wsus/setup.exe) instead of broken fwlink redirect - HttpClient with proper redirect handling, content-type check, file size validation - Selective C2R removal: each product listed separately, only checked items removed - OfficeDetector splits ProductReleaseIds into individual entries - Display Level="Full" for removal (shows Microsoft progress UI) - Confirmation dialog before removal on all pages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,15 +9,16 @@
|
||||
<Company>InstaSoft Zrt.</Company>
|
||||
<Product>InstaSoft Office Tool</Product>
|
||||
<Copyright>Copyright (c) InstaSoft Zrt. 2026</Copyright>
|
||||
<Version>1.0.8</Version>
|
||||
<AssemblyVersion>1.0.8.0</AssemblyVersion>
|
||||
<FileVersion>1.0.8.0</FileVersion>
|
||||
<Version>1.0.9</Version>
|
||||
<AssemblyVersion>1.0.9.0</AssemblyVersion>
|
||||
<FileVersion>1.0.9.0</FileVersion>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
Foreground="{StaticResource TextSecondaryBrush}" Margin="0,-2,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Text="v1.08" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
<TextBlock Text="v1.09" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
FontSize="12" Foreground="{StaticResource TextSecondaryBrush}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -73,7 +73,10 @@ namespace InstaSoftOfficeTool.Pages
|
||||
BtnSkip.IsEnabled = false;
|
||||
LogPanel.Visibility = Visibility.Visible;
|
||||
|
||||
bool hasC2R = false;
|
||||
try
|
||||
{
|
||||
var c2rProducts = new System.Collections.Generic.List<string>();
|
||||
|
||||
foreach (UIElement child in OfficeListPanel.Children)
|
||||
{
|
||||
if (child is CheckBox cb && cb.IsChecked == true)
|
||||
@@ -81,38 +84,49 @@ namespace InstaSoftOfficeTool.Pages
|
||||
var office = (InstalledOffice)cb.Tag;
|
||||
if (office.IsClickToRun)
|
||||
{
|
||||
hasC2R = true;
|
||||
c2rProducts.Add(office.ProductCode);
|
||||
}
|
||||
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");
|
||||
int code = await runner.RunAsync("msiexec", "/x " + office.ProductCode + " /qb");
|
||||
AppendLog("MSI exit code: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasC2R)
|
||||
if (c2rProducts.Count > 0)
|
||||
{
|
||||
AppendLog("Click-to-Run Office elt\u00e1vol\u00edt\u00e1sa...");
|
||||
AppendLog("Click-to-Run term\u00e9kek elt\u00e1vol\u00edt\u00e1sa: " + string.Join(", ", c2rProducts));
|
||||
|
||||
var downloader = new OdtDownloader();
|
||||
downloader.StatusChanged += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
||||
|
||||
bool ok = await downloader.DownloadAndExtractAsync();
|
||||
if (ok)
|
||||
if (!ok)
|
||||
{
|
||||
string removeXml = OdtXmlGenerator.GenerateRemoveAll();
|
||||
AppendLog("HIBA: Az ODT let\u00f6lt\u00e9se sikertelen.");
|
||||
BtnRemove.IsEnabled = true;
|
||||
BtnSkip.IsEnabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
string removeXml = OdtXmlGenerator.GenerateRemoveProducts(c2rProducts.ToArray());
|
||||
string xmlPath = Path.Combine(downloader.OdtFolder, "remove.xml");
|
||||
File.WriteAllText(xmlPath, removeXml);
|
||||
|
||||
AppendLog("Futtat\u00e1s: setup.exe /configure remove.xml");
|
||||
AppendLog("Ez eltarthat n\u00e9h\u00e1ny percig...");
|
||||
|
||||
int exitCode = await downloader.RunRemoveAsync(xmlPath,
|
||||
msg => Dispatcher.Invoke(() => AppendLog(msg)));
|
||||
|
||||
AppendLog("setup.exe exit code: " + exitCode);
|
||||
AppendLog(exitCode == 0
|
||||
? "Office sikeresen elt\u00e1vol\u00edtva."
|
||||
: "Elt\u00e1vol\u00edt\u00e1s befejez\u0151d\u00f6tt (k\u00f3d: " + exitCode + ")");
|
||||
}
|
||||
: "FIGYELEM: Az elt\u00e1vol\u00edt\u00e1s nem siker\u00fclt (k\u00f3d: " + exitCode + ")");
|
||||
}
|
||||
|
||||
if (CbCleanLicense.IsChecked == true)
|
||||
@@ -131,9 +145,13 @@ namespace InstaSoftOfficeTool.Pages
|
||||
}
|
||||
|
||||
AppendLog("K\u00e9sz. Tov\u00e1bbl\u00e9p\u00e9s az \u00faj Office telep\u00edt\u00e9s\u00e9hez...");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendLog("V\u00e1ratlan hiba: " + ex.Message);
|
||||
}
|
||||
|
||||
// Auto-proceed to install after short delay
|
||||
await System.Threading.Tasks.Task.Delay(1500);
|
||||
await System.Threading.Tasks.Task.Delay(2000);
|
||||
_main.ProceedToInstall();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,10 @@ namespace InstaSoftOfficeTool.Pages
|
||||
BtnRemove.IsEnabled = false;
|
||||
LogPanel.Visibility = Visibility.Visible;
|
||||
|
||||
bool hasC2R = false;
|
||||
try
|
||||
{
|
||||
var c2rProducts = new System.Collections.Generic.List<string>();
|
||||
|
||||
foreach (UIElement child in OfficeListPanel.Children)
|
||||
{
|
||||
if (child is CheckBox cb && cb.IsChecked == true)
|
||||
@@ -69,43 +72,63 @@ namespace InstaSoftOfficeTool.Pages
|
||||
var office = (InstalledOffice)cb.Tag;
|
||||
if (office.IsClickToRun)
|
||||
{
|
||||
hasC2R = true;
|
||||
c2rProducts.Add(office.ProductCode);
|
||||
}
|
||||
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");
|
||||
int code = await runner.RunAsync("msiexec", "/x " + office.ProductCode + " /qb");
|
||||
AppendLog("MSI exit code: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasC2R)
|
||||
if (c2rProducts.Count > 0)
|
||||
{
|
||||
AppendLog("Click-to-Run Office elt\u00e1vol\u00edt\u00e1sa ODT-vel...");
|
||||
AppendLog("Click-to-Run term\u00e9kek elt\u00e1vol\u00edt\u00e1sa: " + string.Join(", ", c2rProducts));
|
||||
|
||||
var downloader = new OdtDownloader();
|
||||
downloader.StatusChanged += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
||||
|
||||
bool ok = await downloader.DownloadAndExtractAsync();
|
||||
if (ok)
|
||||
if (!ok)
|
||||
{
|
||||
string removeXml = OdtXmlGenerator.GenerateRemoveAll();
|
||||
AppendLog("HIBA: Az ODT let\u00f6lt\u00e9se sikertelen.");
|
||||
BtnRemove.IsEnabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
string removeXml = OdtXmlGenerator.GenerateRemoveProducts(c2rProducts.ToArray());
|
||||
string xmlPath = Path.Combine(downloader.OdtFolder, "remove.xml");
|
||||
File.WriteAllText(xmlPath, removeXml);
|
||||
|
||||
AppendLog("Remove XML:");
|
||||
AppendLog(removeXml);
|
||||
AppendLog("");
|
||||
AppendLog("Futtat\u00e1s: setup.exe /configure remove.xml");
|
||||
AppendLog("Ez eltarthat n\u00e9h\u00e1ny percig...");
|
||||
|
||||
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 + ")");
|
||||
AppendLog("setup.exe exit code: " + exitCode);
|
||||
|
||||
if (exitCode == 0)
|
||||
{
|
||||
AppendLog("Office sikeresen elt\u00e1vol\u00edtva.");
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendLog("FIGYELEM: Az elt\u00e1vol\u00edt\u00e1s nem siker\u00fclt (k\u00f3d: " + exitCode + ")");
|
||||
AppendLog("Pr\u00f3b\u00e1lja meg manu\u00e1lisan: Vez\u00e9rl\u0151pult > Programok elt\u00e1vol\u00edt\u00e1sa");
|
||||
}
|
||||
}
|
||||
|
||||
if (CbCleanLicense.IsChecked == true)
|
||||
{
|
||||
AppendLog("");
|
||||
AppendLog("Licenc-adatb\u00e1zis tiszt\u00edt\u00e1sa...");
|
||||
var lm = new LicenseManager();
|
||||
if (lm.FindOspp())
|
||||
@@ -119,7 +142,15 @@ namespace InstaSoftOfficeTool.Pages
|
||||
}
|
||||
}
|
||||
|
||||
AppendLog("");
|
||||
AppendLog("K\u00e9sz.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendLog("V\u00e1ratlan hiba: " + ex.Message);
|
||||
AppendLog(ex.StackTrace);
|
||||
}
|
||||
|
||||
_main.ShowCloseButton();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InstaSoftOfficeTool.Services
|
||||
{
|
||||
public class OdtDownloader
|
||||
{
|
||||
private const string OdtDownloadUrl = "https://go.microsoft.com/fwlink/p/?LinkID=626065";
|
||||
// Direct CDN link to ODT setup.exe (no self-extractor needed)
|
||||
private const string OdtDownloadUrl = "https://officecdn.microsoft.com/pr/wsus/setup.exe";
|
||||
|
||||
public event Action<string> StatusChanged;
|
||||
public event Action<int> ProgressChanged;
|
||||
|
||||
public string OdtFolder { get; private set; }
|
||||
public string SetupExePath { get; private set; }
|
||||
@@ -24,53 +24,70 @@ namespace InstaSoftOfficeTool.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(OdtFolder);
|
||||
|
||||
var odtExePath = Path.Combine(OdtFolder, "officedeploymenttool.exe");
|
||||
SetupExePath = Path.Combine(OdtFolder, "setup.exe");
|
||||
|
||||
// Check if valid setup.exe already exists
|
||||
if (File.Exists(SetupExePath))
|
||||
{
|
||||
StatusChanged?.Invoke("Az ODT setup.exe m\u00e1r el\u00e9rhet\u0151, let\u00f6lt\u00e9s kihagyva.");
|
||||
var existingSize = new FileInfo(SetupExePath).Length;
|
||||
if (existingSize > 1000000) // valid setup.exe is ~7MB
|
||||
{
|
||||
StatusChanged?.Invoke("Az ODT setup.exe m\u00e1r el\u00e9rhet\u0151 (" +
|
||||
(existingSize / 1024 / 1024) + " MB).");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Delete corrupted file
|
||||
StatusChanged?.Invoke("S\u00e9r\u00fclt setup.exe t\u00f6rl\u00e9se...");
|
||||
File.Delete(SetupExePath);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(OdtFolder);
|
||||
|
||||
// Download setup.exe directly from CDN
|
||||
StatusChanged?.Invoke("Office Deployment Tool let\u00f6lt\u00e9se...");
|
||||
StatusChanged?.Invoke("URL: " + OdtDownloadUrl);
|
||||
|
||||
using (var client = new WebClient())
|
||||
using (var handler = new HttpClientHandler { AllowAutoRedirect = true })
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
client.DownloadProgressChanged += (s, e) =>
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "InstaSoftOfficeTool/1.0");
|
||||
client.Timeout = TimeSpan.FromMinutes(5);
|
||||
|
||||
var response = await client.GetAsync(OdtDownloadUrl);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
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 + ")");
|
||||
StatusChanged?.Invoke("Hiba: HTTP " + (int)response.StatusCode + " " + response.StatusCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!File.Exists(SetupExePath))
|
||||
var contentType = response.Content.Headers.ContentType?.MediaType ?? "";
|
||||
if (contentType.Contains("text/html"))
|
||||
{
|
||||
StatusChanged?.Invoke("Hiba: A setup.exe nem tal\u00e1lhat\u00f3 a kicsomagol\u00e1s ut\u00e1n.");
|
||||
StatusChanged?.Invoke("Hiba: HTML oldal \u00e9rkezett exe helyett.");
|
||||
StatusChanged?.Invoke("T\u00f6ltse le manu\u00e1lisan: https://www.microsoft.com/en-us/download/details.aspx?id=49117");
|
||||
return false;
|
||||
}
|
||||
|
||||
StatusChanged?.Invoke("ODT sikeresen let\u00f6ltve \u00e9s kicsomagolva.");
|
||||
var bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
File.WriteAllBytes(SetupExePath, bytes);
|
||||
|
||||
StatusChanged?.Invoke("Let\u00f6ltve: " + (bytes.Length / 1024) + " KB");
|
||||
}
|
||||
|
||||
if (!File.Exists(SetupExePath) || new FileInfo(SetupExePath).Length < 1000000)
|
||||
{
|
||||
StatusChanged?.Invoke("Hiba: A let\u00f6lt\u00f6tt f\u00e1jl s\u00e9r\u00fclt vagy t\u00fal kicsi.");
|
||||
return false;
|
||||
}
|
||||
|
||||
StatusChanged?.Invoke("ODT setup.exe k\u00e9sz.");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusChanged?.Invoke("Hiba a let\u00f6lt\u00e9s sor\u00e1n: " + ex.Message);
|
||||
StatusChanged?.Invoke("Hiba: " + ex.GetType().Name + ": " + ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,31 @@ namespace InstaSoftOfficeTool.Services
|
||||
new XElement("Remove", new XAttribute("All", "TRUE")),
|
||||
new XElement("Display",
|
||||
new XAttribute("Level", "Full"),
|
||||
new XAttribute("AcceptEULA", "TRUE")));
|
||||
new XAttribute("AcceptEULA", "TRUE")),
|
||||
new XElement("Property",
|
||||
new XAttribute("Name", "FORCEAPPSHUTDOWN"),
|
||||
new XAttribute("Value", "TRUE")));
|
||||
|
||||
var doc = new XDocument(new XDeclaration("1.0", "utf-8", null), configuration);
|
||||
return doc.Declaration + "\n" + doc.Root;
|
||||
}
|
||||
|
||||
public static string GenerateRemoveProducts(string[] productIds)
|
||||
{
|
||||
var remove = new XElement("Remove");
|
||||
foreach (var id in productIds)
|
||||
{
|
||||
remove.Add(new XElement("Product", new XAttribute("ID", id)));
|
||||
}
|
||||
|
||||
var configuration = new XElement("Configuration",
|
||||
remove,
|
||||
new XElement("Display",
|
||||
new XAttribute("Level", "Full"),
|
||||
new XAttribute("AcceptEULA", "TRUE")),
|
||||
new XElement("Property",
|
||||
new XAttribute("Name", "FORCEAPPSHUTDOWN"),
|
||||
new XAttribute("Value", "TRUE")));
|
||||
|
||||
var doc = new XDocument(new XDeclaration("1.0", "utf-8", null), configuration);
|
||||
return doc.Declaration + "\n" + doc.Root;
|
||||
|
||||
@@ -31,12 +31,20 @@ namespace InstaSoftOfficeTool.Services
|
||||
var productIds = key.GetValue("ProductReleaseIds") as string;
|
||||
var versionToReport = key.GetValue("VersionToReport") as string;
|
||||
|
||||
if (!string.IsNullOrEmpty(productIds))
|
||||
if (string.IsNullOrEmpty(productIds)) return;
|
||||
|
||||
// Split into individual products (e.g. "O365BusinessRetail,VisioProRetail")
|
||||
var ids = productIds.Split(',');
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var trimmedId = id.Trim();
|
||||
if (string.IsNullOrEmpty(trimmedId)) continue;
|
||||
|
||||
results.Add(new InstalledOffice
|
||||
{
|
||||
DisplayName = "Microsoft Office Click-to-Run (" + productIds + ")",
|
||||
DisplayName = "Microsoft Office Click-to-Run (" + trimmedId + ")",
|
||||
Version = versionToReport ?? "",
|
||||
ProductCode = trimmedId,
|
||||
IsClickToRun = true,
|
||||
IsSelected = true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user