Skip to content

Commit

Permalink
增加激活 Office 异常时,自动修复的功能。优化其他交互体验。
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusYuan committed Dec 13, 2022
1 parent 8cf13ae commit e2596f7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion LKY_OfficeTools/Lib/Lib_AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal class AppAttribute
/// <summary>
/// APP 版本号
/// </summary>
internal const string AppVersion = "1.1.1.1209";
internal const string AppVersion = "1.1.1.1213";

/// <summary>
/// 开发者拼音全拼
Expand Down
6 changes: 6 additions & 0 deletions LKY_OfficeTools/Lib/Lib_OfficeActivate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ internal static int StartActivate(string kms_server = "kms.chinancce.com")
new Log($" × 系统可能存在损坏,建议您重新安装操作系统后重试!", ConsoleColor.DarkRed);
return -101; //返回无限小,不再重试
}
//0xC004F074
else if (log_activate.Contains("0xC004F074"))
{
//0xC004F074错误:与KMS服务器通讯失败
new Log($" × 激活失败!若此消息频频复现,强烈建议您重置网卡设置 或 重新安装操作系统!", ConsoleColor.DarkRed);
}
else
{
//非已知问题
Expand Down
14 changes: 7 additions & 7 deletions LKY_OfficeTools/Lib/Lib_OfficeClean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ internal static bool Delete()

//逐一卸载后,若都为 success,则再执行一次检查
office_installed_key = OfficeLocalInstall.LicenseInfo(); //再度获取list
if (office_installed_key == null) //为空,视为成功
if (office_installed_key.Count == 0) //为0,视为成功
{
return true;
}
Expand Down Expand Up @@ -387,11 +387,11 @@ internal static bool BySaRA()

//执行卸载命令
string cmd_switch_cd = $"pushd \"{SaRA_path_root}\""; //切换至SaRA文件目录
string cmd_unstall = $"SaRACmd.exe -S OfficeScrubScenario -AcceptEula -Officeversion All";
string uninstall_result = Com_ExeOS.Run.Cmd($"({cmd_switch_cd})&({cmd_unstall})");
string cmd_uninstall = $"SaRACmd.exe -S OfficeScrubScenario -AcceptEula -Officeversion All";
string uninstall_result = Com_ExeOS.Run.Cmd($"({cmd_switch_cd})&({cmd_uninstall})");
if (!uninstall_result.ToLower().Contains("successful"))
{
new Log(uninstall_result);
new Log($"SaRA Exception: \n{uninstall_result}");
new Log($" × 卸载 Office 冗余版本失败!", ConsoleColor.DarkRed);
return false;
}
Expand Down Expand Up @@ -462,11 +462,10 @@ internal static bool ByODT()
//测试表明,卸载1个ODT版本大约需要2分钟时间,留出2倍的富余
new Log($" >> 此过程大约会在 {Math.Ceiling(install_list.Count * 2 * 2.0f)} 分钟内完成,具体时间取决于您的电脑配置,请稍候 ...", ConsoleColor.DarkYellow);

//移除所有激活信息
//移除所有激活信息,即使有错误也继续执行后续卸载。
if (!Activate.Delete())
{
new Log(" × 移除激活信息失败!");
return false;
new Log("移除激活信息失败!"); //纯打点
}

new Log($" >> 卸载仍在继续,请等待其自动完成 ...", ConsoleColor.DarkYellow);
Expand All @@ -486,6 +485,7 @@ internal static bool ByODT()
//注册表ODT至少存在1个版本时,视为卸载失败
if (reg_info != null && reg_info.Count > 0)
{
new Log($"ODT UnInstalling Exception ExitCode: {uninstall_code}");
new Log($" × 已尝试卸载 Office ODT 版本,但系统仍存在 {reg_info.Count} 个无法卸载的版本!", ConsoleColor.DarkRed);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion LKY_OfficeTools/OfficeTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class OfficeTools
static void Main(string[] args)
{
//设定编码,解决英文系统乱码问题
Console.OutputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.GetEncoding("gbk");

//命令行检测
new Lib_AppCommand(args);
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- 当系统中存在多个冗余 Office 版本时,本工具在用户同意的情况下,可实现自动升级。

## 使用方法
- 解压形如:LKY_OfficeTools_v*.zip 的文件,运行解压后目录下的 LKY_OfficeTools.exe 文件即可完成部署。
- 下载形如:LKY_OfficeTools_v*.zip 的压缩包,地址:https://gitee.com/OdysseusYuan/LKY_OfficeTools/releases/latest
- 解压下载好的 zip 压缩包,运行解压后目录下的 LKY_OfficeTools.exe 文件即可完成部署。

## 测试环境
- 目前已经在 Windows 10(1703) 及以上版本进行了测试,均可在其 x86、x64 完美安装正版 Office 并激活。
Expand Down

0 comments on commit e2596f7

Please sign in to comment.