Skip to content

Commit 82beb50

Browse files
committed
automatic office deplyment, bug fixes
1 parent c8c9df3 commit 82beb50

File tree

10 files changed

+43
-19
lines changed

10 files changed

+43
-19
lines changed

office_deploy/install-office.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
@echo off
2-
echo Downloading Office, please wait...
3-
.\setup.exe /download .\office-proplus.xml
4-
echo Installing Office...
52
.\setup.exe /configure .\office-proplus.xml
3+
@echo on

office_deploy/kms-activate.exe

227 KB
Binary file not shown.

win10-activate/ActOffice.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using System;
44
using System.Diagnostics;
5+
using System.IO;
56
using System.Windows;
67

78
namespace kms_activate
@@ -11,6 +12,11 @@ class ActOffice
1112
public static MainWindow mainW = (MainWindow)Application.Current.MainWindow;
1213
public static void OfficeActivate()
1314
{
15+
if (!OfficeEnv())
16+
{
17+
Application.Current.Shutdown();
18+
}
19+
MessageBox.Show("Make sure to open Office and agree to user terms", "Tips", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
1420

1521
// debug info
1622
string kmsServerDbg, activateDbg;
@@ -244,7 +250,18 @@ public static void Retail2Vol(string installRoot)
244250
MessageBox.Show("Converting Office " + version + " retail version to volume version...\n" + log, "Note: You are NOT using volume version", MessageBoxButton.OK, MessageBoxImage.Information);
245251
}
246252

247-
public static void OfficeEnv()
253+
public static void InstallOffice()
254+
{
255+
if (!File.Exists("setup.exe") || !File.Exists("office-proplus.xml"))
256+
{
257+
MessageBox.Show("Make sure setup.exe and office-proplus.xml exist in current directory", "Files missing",
258+
MessageBoxButton.OK, MessageBoxImage.Error);
259+
return;
260+
}
261+
Util.RunProcess("setup.exe", "/configure office-proplus.xml", "./", true);
262+
}
263+
264+
public static bool OfficeEnv()
248265
{
249266

250267
// look for Office's install path, where OSPP.VBS can be found
@@ -295,13 +312,20 @@ public static void OfficeEnv()
295312
MessageBox.Show("Only works with Office 2010 and/or above", "Unsupported version", MessageBoxButton.OK, MessageBoxImage.Error);
296313
mainW.button.Content = "Unsupported version";
297314
mainW.windows_option.IsChecked = true;
298-
return;
315+
return false;
299316
}
300317
mainW.OsppPath.Text = officepath;
318+
319+
return true;
301320
}
302321
catch (Exception err)
303322
{
304-
MessageBox.Show(err.ToString(), "Error detecting Office path", MessageBoxButton.OK, MessageBoxImage.Error);
323+
MessageBox.Show("Office installation not detected:\n" + err.ToString(), "Error detecting Office path", MessageBoxButton.OK);
324+
if (Util.YesNo("Download and install Office 2021 with Office Deployment Tool?", "Install Office"))
325+
{
326+
InstallOffice();
327+
}
328+
return false;
305329
}
306330
}
307331
}

win10-activate/ActWin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using Microsoft.Win32;
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Diagnostics;
46
using System.Windows;
57

6-
using Microsoft.Win32;
7-
88
namespace kms_activate
99
{
1010
class ActWin

win10-activate/App.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
55
</startup>
6-
</configuration>
6+
</configuration>

win10-activate/MainWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ public MainWindow()
1717
}
1818
InitializeComponent();
1919
windows_option.IsChecked = true;
20+
ShowDebug.IsChecked = true;
2021
}
2122

2223
private void Button_Click(object sender, RoutedEventArgs e)
2324
{
2425
// when to exit
25-
if ((string)button.Content == "Done! Click to exit")
26+
if (button.Content.ToString() == "Done! Click to exit")
2627
{
2728
Application.Current.Shutdown();
2829
}

win10-activate/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

win10-activate/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

win10-activate/Properties/app.manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
Remove this element if your application requires this virtualization for backwards
1717
compatibility.
1818
-->
19-
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
19+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
2020
</requestedPrivileges>
2121
<applicationRequestMinimum>
2222
<defaultAssemblyRequest permissionSetReference="Custom" />
23-
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
23+
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
2424
</applicationRequestMinimum>
2525
</security>
2626
</trustInfo>

win10-activate/kms-activate.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>kms_activate</RootNamespace>
1111
<AssemblyName>kms-activate</AssemblyName>
12-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515
<WarningLevel>4</WarningLevel>
@@ -30,6 +30,7 @@
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<PublishWizardCompleted>true</PublishWizardCompleted>
3232
<BootstrapperEnabled>true</BootstrapperEnabled>
33+
<TargetFrameworkProfile />
3334
</PropertyGroup>
3435
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3536
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -57,7 +58,7 @@
5758
<ManifestKeyFile>win10-activate_TemporaryKey.pfx</ManifestKeyFile>
5859
</PropertyGroup>
5960
<PropertyGroup>
60-
<GenerateManifests>true</GenerateManifests>
61+
<GenerateManifests>false</GenerateManifests>
6162
</PropertyGroup>
6263
<PropertyGroup>
6364
<SignManifests>false</SignManifests>

0 commit comments

Comments
 (0)