Skip to content

Commit

Permalink
实现软件更新后,自动执行后续任务的能力。
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusYuan committed Nov 7, 2022
1 parent 6a84f75 commit bef5d6c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
5 changes: 4 additions & 1 deletion LKY_OfficeTools/Lib/Lib_SelfUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ internal static bool Check_Latest_Version()
Thread.Sleep(5000);

//启动实例
Process.Start(Process.GetCurrentProcess().MainModule.FileName);
Process p = new Process();
p.StartInfo.FileName = Process.GetCurrentProcess().MainModule.FileName; //需要启动的程序名
p.StartInfo.Arguments = "/none_welcome_confirm"; //启动参数
p.Start();
//关闭当前实例
Process.GetCurrentProcess().Kill();
}
Expand Down
29 changes: 23 additions & 6 deletions LKY_OfficeTools/OfficeTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ internal class OfficeTools
{
static void Main(string[] args)
{
Entry();
//命令行检测
string arg = null;
foreach (var now_arg in args)
{
arg += now_arg + ";";
}

Entry(arg);
}

/// <summary>
/// 函数入口
/// </summary>
private static void Entry()
private static void Entry(string args = null)
{
//欢迎话术
Version version = Assembly.GetExecutingAssembly().GetName().Version;
Expand Down Expand Up @@ -59,10 +66,20 @@ private static void Entry()
return;
}

//等待用户
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\n请按 回车键 开始部署 ...");
if (Console.ReadKey().Key == ConsoleKey.Enter)
//根据命令行判断是否等待用户
bool isContinue = false;
if (!string.IsNullOrEmpty(args) && args.Contains("/none_welcome_confirm"))
{
isContinue = true;
}
else
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\n请按 回车键 开始部署 ...");
isContinue = (Console.ReadKey().Key == ConsoleKey.Enter);
}

if (isContinue)
{
//权限检查
Com_PrivilegeOS.PrivilegeAttention();
Expand Down

0 comments on commit bef5d6c

Please sign in to comment.