Program.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Threading;
  6. using System.Windows.Forms;
  7. namespace Start
  8. {
  9. static class Program
  10. {
  11. /// <summary>
  12. /// 应用程序的主入口点。
  13. /// </summary>
  14. [STAThread]
  15. static void Main()
  16. {
  17. renamefiles();
  18. }
  19. private static void renamefiles()
  20. {
  21. try
  22. {
  23. //const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
  24. ////判断是否安装.net framework4.5.2
  25. //using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
  26. //{
  27. // if (ndpKey != null && (int)ndpKey.GetValue("Release") >= 379893)
  28. // {
  29. // }
  30. // else
  31. // {
  32. // MessageBox.Show("即将开始安装.Net运行环境,请在安装完成后重新启动游戏程序.");
  33. // Process.Start(".\\NDP452-KB2901907-x86-x64-AllOS-ENU.exe");
  34. // Environment.Exit(1);
  35. // }
  36. //}
  37. if (File.Exists(".\\updates_rename.log"))
  38. {
  39. Thread.Sleep(500);
  40. string[] files = File.ReadAllLines(".\\updates_rename.log");
  41. foreach (string file in files)
  42. {
  43. if (File.Exists(file + ".bak"))
  44. {
  45. if (File.Exists(file)) File.Delete(file);
  46. File.Move(file + ".bak", file);
  47. }
  48. }
  49. File.Delete("updates_rename.log");
  50. };
  51. Thread.Sleep(200);
  52. try
  53. {
  54. Process.Start(".\\Mir3AU.exe");
  55. }
  56. catch
  57. {
  58. File.Copy(".\\Mir3AU.exe", ".\\Mir3AU2.exe", true);
  59. Thread.Sleep(200);
  60. Process.Start(".\\Mir3AU2.exe");
  61. }
  62. // System.Environment.Exit(0);
  63. }
  64. catch { }
  65. }
  66. }
  67. }