Upgrade to v2.5
UI optimization. UI界面美化。 Added a feature of log output to file. use `-l` or `-log` argument 添加了日志输出到文件功能。 使用 `-l` or `-log` 参数. The UI theme now follows the Windows 10 application theme changes. (Dark or Light.) 现在界面主题会跟随 Windows10 应用主题变化。(暗色或者亮色。) Japanese language localization file updated. 日语本地化语言文件更新。 Fixed some issues about UI animation. (Thanks for Keboo) 修复了UI上的一些动画问题。(感谢 Keboo) Fixed an issue of LTOK not work. 修复了LTOK不能正常工作的问题。 Fixed an issue that could cause a stuck when activated. 修复了激活时可能导致卡住的问题。 Fixed an issue that crashed when running again after a forced stop. 修复了在强制关闭程序后再次运行时会崩溃的问题。 Now it will never leave any redundant registry entries anymore when the problem occurs. 现在它将再也不会在发生问题时留下任何冗余的注册表项。 Code optimization. 优化代码。
This commit is contained in:
parent
ce21e6484b
commit
b30a728aeb
@ -67,7 +67,7 @@
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignThemes.Wpf, Version=2.5.0.1205, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignThemes.2.5.0.1205\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
@ -78,6 +78,7 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime" />
|
||||
<Reference Include="System.Runtime.InteropServices.WindowsRuntime" />
|
||||
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@ -161,9 +162,15 @@
|
||||
<Resource Include="CMWTAT.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Res\MaterialDesignColors.dll" />
|
||||
<EmbeddedResource Include="Res\MaterialDesignThemes.Wpf.dll" />
|
||||
<EmbeddedResource Include="Res\Newtonsoft.Json.dll" />
|
||||
<EmbeddedResource Include="..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll">
|
||||
<Link>Res\MaterialDesignColors.dll</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\packages\MaterialDesignThemes.2.5.0.1205\lib\net45\MaterialDesignThemes.Wpf.dll">
|
||||
<Link>Res\MaterialDesignThemes.Wpf.dll</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll">
|
||||
<Link>Res\Newtonsoft.Json.dll</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
|
@ -15,7 +15,6 @@
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
<StartArguments>-l -%3f</StartArguments>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -1,7 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<!--
|
||||
Version: 2.4.0.0
|
||||
Version: 2.5.0.0
|
||||
-->
|
||||
|
||||
<!--FontFamily Dictionary-->
|
||||
@ -169,7 +169,7 @@
|
||||
-->
|
||||
|
||||
<sys:String x:Key="HelpText" xml:space="preserve">
|
||||
This application now supports the use of console args to startup! -a	--auto		Auto activate. -h	--hide		Run with hide mode (Only be worked with -auto). -e	--expact		Experimental activation. -?	--help		Show this help Dialog.
|
||||
This application now supports the use of console args to startup! -a	--auto		Auto activate. -h	--hide		Run with hide mode (Only be worked with -auto). -e	--expact		Experimental activation. -l	--log		Output log to file. -?	--help		Show this help Dialog.
|
||||
</sys:String>
|
||||
<sys:String x:Key="DonateTextConverted" xml:space="preserve">
|
||||
Congratulation! Windows 10 has been successful converted.
|
||||
|
@ -1,7 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<!--
|
||||
Version: 2.3.0.1
|
||||
Version: 2.5.0.0
|
||||
-->
|
||||
|
||||
<!--FontFamily Dictionary-->
|
||||
@ -169,7 +169,7 @@
|
||||
-->
|
||||
|
||||
<sys:String x:Key="HelpText" xml:space="preserve">
|
||||
このアプリは起動時にコンソール引数を使用できるようになりました! -a	--auto		自動認証。 -h	--hide		非表示モードで実行 (-autoと一緒に使用するだけ可能)。 -e	--expact		実験性認証。 -?	--help		この説明ダイアログボックスを表示する。
|
||||
このアプリは起動時にコンソール引数を使用できるようになりました! -a	--auto		自動認証。 -h	--hide		非表示モードで実行 (-autoと一緒に使用するだけ可能)。 -e	--expact		実験性認証。 -l	--log		ログをファイルに出力。 -?	--help		この説明ダイアログボックスを表示する。
|
||||
</sys:String>
|
||||
<sys:String x:Key="DonateTextConverted" xml:space="preserve">
|
||||
おめでとう! Windows 10 エディション変換成功。
|
||||
@ -205,9 +205,9 @@ Windows10ライセンス認証にはインターネットを通じてキーを
|
||||
認証失敗。 :( 多分: 1. このエディション/バージョンの Windows はデジタルライセンス認証が適用しない。 2. マイクロソフトの認証サーバーに接続できません。 3. その他。 暫くお待ちくださいまたはあとでもう一度やり直してください。
|
||||
</sys:String>
|
||||
<sys:String x:Key="Only_find_ltok" xml:space="preserve">
|
||||
Only found Long-Term Offline KMS (LTOK) options that can be used with this operating system edition. This means that it will not be activate automatically after you reinstalled the system. But don't worry, this is different from the legacy KMS activation method (it can keep activating for 180 days in offline environment). LTOK (The prefix is Offline-KMS) can keep activating for up to 19 years even it is without networking!
|
||||
</sys:String>
|
||||
このシステムエディションに適用されたのは長期オフラインKMS(LTOK)オプションしか見つかりません。これによってシステムを再インストールした時自動的にライセンス認証しませんが、心配する必要はありません。この方法(LTOK)でライセンス認証後、インターネット接続なしでも最大19年間稼働を継続できます!
|
||||
</sys:String>
|
||||
<sys:String x:Key="DonateTextWillActivated" xml:space="preserve">
|
||||
Congratulation! Windows 10 is ready to activate. However, it seems that Windows cannot connect to the Microsoft Activation Server. Your system will be activated automatically the next time the server is connected.
|
||||
おめでとうございます! Windows 10はライセンス認証の準備が出来ています。 でも、マイクロソフトのライセンス認証サーバーに接続できませんみたいです。 システムは認証サーバーに接続出来る次第に自動的にライセンス認証します。
|
||||
</sys:String>
|
||||
</ResourceDictionary>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<!--
|
||||
Version: 2.4.0.0
|
||||
Version: 2.5.0.0
|
||||
-->
|
||||
|
||||
<!--FontFamily Dictionary-->
|
||||
@ -169,7 +169,7 @@
|
||||
-->
|
||||
|
||||
<sys:String x:Key="HelpText" xml:space="preserve">
|
||||
这个应用现已支持通过控制台参数启动! -a	--auto		自动激活。 -h	--hide		隐藏模式运行 (只能与 -auto 一起使用)。 -e	--expact		实验性激活。 -?	--help		显示此说明对话框。
|
||||
这个应用现已支持通过控制台参数启动! -a	--auto		自动激活。 -h	--hide		隐藏模式运行 (只能与 -auto 一起使用)。 -e	--expact	实验性激活。 -l	--log		输出日志到文件。 -?	--help		显示此说明对话框。
|
||||
</sys:String>
|
||||
<sys:String x:Key="DonateTextConverted" xml:space="preserve">
|
||||
祝贺! Windows 10 已经成功转换。
|
||||
|
@ -19,15 +19,17 @@
|
||||
Icon="CMWTAT.ico"
|
||||
Closing="Window_Closing"
|
||||
FontFamily="{DynamicResource Font}"
|
||||
Activated="Window_Activated"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
>
|
||||
<!--FontFamily="{DynamicResource MaterialDesignFont}"-->
|
||||
<Grid>
|
||||
<Grid Margin="30,30,30,30" VerticalAlignment="Center">
|
||||
<StackPanel>
|
||||
<materialDesign:Card Padding="30" Margin="0,0,0,0">
|
||||
<materialDesign:Card Padding="30" Margin="0,0,0,0" materialDesign:ShadowAssist.ShadowDepth="Depth3" UniformCornerRadius="8">
|
||||
<TextBlock FontFamily="{DynamicResource Font}" Style="{DynamicResource MaterialDesignTitleTextBlock}" ><Run Text="{DynamicResource AppName}"/></TextBlock>
|
||||
</materialDesign:Card>
|
||||
<materialDesign:Card Padding="30,30" Margin="0,30,0,0">
|
||||
<materialDesign:Card Padding="30,30" Margin="0,30,0,0" materialDesign:ShadowAssist.ShadowDepth="Depth3" UniformCornerRadius="8">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<ComboBox x:Name="SystemEditionText" DisplayMemberPath="DisplayOS" VerticalAlignment="Center" Visibility="Visible"/>
|
||||
@ -48,15 +50,19 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
<Button FontFamily="{DynamicResource Font}" x:Name="actbtn" Content="{DynamicResource Activate_Button}" Margin="0,30,0,0" VerticalAlignment="Top" Click="Activate_Button_Click" Height="65"/>
|
||||
<Button FontFamily="{DynamicResource Font}" x:Name="installbtn" Content="{DynamicResource Convert_versions}" Margin="0,30,0,0" VerticalAlignment="Top" Click="installbtn_Click" Height="65"/>
|
||||
<materialDesign:Card Margin="0,30,0,0" VerticalAlignment="Top" materialDesign:ShadowAssist.ShadowDepth="Depth3" Height="65" UniformCornerRadius="8">
|
||||
<Button FontFamily="{DynamicResource Font}" x:Name="actbtn" Content="{DynamicResource Activate_Button}" materialDesign:ShadowAssist.ShadowDepth="Depth0" Click="Activate_Button_Click" Margin="0" Height="65" />
|
||||
</materialDesign:Card>
|
||||
<materialDesign:Card Margin="0,30,0,0" VerticalAlignment="Top" materialDesign:ShadowAssist.ShadowDepth="Depth3" Height="65" UniformCornerRadius="8">
|
||||
<Button FontFamily="{DynamicResource Font}" x:Name="installbtn" Content="{DynamicResource Convert_versions}" materialDesign:ShadowAssist.ShadowDepth="Depth0" Click="installbtn_Click" Margin="0" Height="65"/>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid x:Name="DialogHostGrid" Visibility="Hidden">
|
||||
<materialDesign:DialogHost x:Name="DialogWait" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="32,24,32,24">
|
||||
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />
|
||||
@ -70,7 +76,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogActProg" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="32,24,32,24">
|
||||
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />
|
||||
@ -84,7 +90,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogWithCancel" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="24,24,24,8">
|
||||
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />
|
||||
@ -104,7 +110,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogWithOK" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
@ -125,7 +131,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogHelp" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
@ -146,7 +152,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogWithExit" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
@ -166,7 +172,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogWithOKToCloseDialog" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
@ -186,7 +192,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogWithOKToCloseDialogDonate" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
@ -207,7 +213,7 @@
|
||||
<materialDesign:DialogHost x:Name="DialogUpdate" IsOpen="False">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<materialDesign:Card>
|
||||
<materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
|
||||
<StackPanel>
|
||||
<StackPanel Margin="16,16,16,8">
|
||||
<!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->
|
||||
|
@ -24,6 +24,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
|
||||
namespace CMWTAT_DIGITAL
|
||||
{
|
||||
@ -47,6 +48,42 @@ namespace CMWTAT_DIGITAL
|
||||
public string DisplayOS { get; set; }
|
||||
}
|
||||
|
||||
public static void ConsoleLog(string log_text = "")
|
||||
{
|
||||
Console.WriteLine(log_text);
|
||||
if (Program.log2file == true)
|
||||
{
|
||||
WriteLog(log_text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteLog(string strLog)
|
||||
{
|
||||
string sFilePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string sFileName = "CMWTAT-" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
|
||||
sFileName = sFilePath + sFileName; //文件的绝对路径
|
||||
if (!Directory.Exists(sFilePath))//验证路径是否存在
|
||||
{
|
||||
Directory.CreateDirectory(sFilePath);
|
||||
//不存在则创建
|
||||
}
|
||||
FileStream fs;
|
||||
StreamWriter sw;
|
||||
if (File.Exists(sFileName))
|
||||
//验证文件是否存在,有则追加,无则创建
|
||||
{
|
||||
fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write);
|
||||
}
|
||||
sw = new StreamWriter(fs);
|
||||
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " --- " + strLog);
|
||||
sw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
string tempfile = System.IO.Path.GetTempPath() + @"CMWTAT_DIGITAL\";
|
||||
|
||||
public void DelectTempFile()
|
||||
@ -73,7 +110,9 @@ namespace CMWTAT_DIGITAL
|
||||
FileAttributes attr = File.GetAttributes(tempfile);
|
||||
if (attr == FileAttributes.Directory)
|
||||
{
|
||||
|
||||
Directory.Delete(tempfile, true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -82,7 +121,7 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("DelectTempFile:" + e.Message);
|
||||
ConsoleLog("DelectTempFile:" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,12 +138,24 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
if (Directory.Exists(tempfile))
|
||||
{
|
||||
ConsoleLog("找到已存在的缓存,开始删除");
|
||||
DelectTempFile();
|
||||
} else
|
||||
{
|
||||
Directory.CreateDirectory(tempfile);
|
||||
ConsoleLog("删除操作完毕");
|
||||
if (Directory.Exists(tempfile))
|
||||
{
|
||||
ConsoleLog("检测到文件依旧存在,等待三秒");
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleLog("确认完毕");
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleLog("开始创建缓存");
|
||||
Directory.CreateDirectory(tempfile);
|
||||
ConsoleLog("创建缓存完毕");
|
||||
|
||||
byte[] temp;
|
||||
System.IO.FileStream fileStream;
|
||||
|
||||
@ -174,6 +225,11 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyBase(bool isDark)
|
||||
{
|
||||
new PaletteHelper().SetLightDark(isDark);
|
||||
}
|
||||
|
||||
string ProductVersion = "0.0.0.0"; // 存储程序版本
|
||||
|
||||
/// <summary>
|
||||
@ -183,7 +239,7 @@ namespace CMWTAT_DIGITAL
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
Console.WriteLine("AppAssemblyFullName: " + assembly.FullName);
|
||||
ConsoleLog("AppAssemblyFullName: " + assembly.FullName);
|
||||
|
||||
// 获取程序集元数据
|
||||
AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)
|
||||
@ -195,35 +251,72 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
ProductVersion = System.Windows.Forms.Application.ProductVersion;
|
||||
|
||||
Console.WriteLine("AppDescription: " + description.Description);
|
||||
Console.WriteLine("AppCopyright: " + copyright.Copyright);
|
||||
Console.WriteLine("AppProductVersion: " + System.Windows.Forms.Application.ProductVersion);
|
||||
ConsoleLog("AppDescription: " + description.Description);
|
||||
ConsoleLog("AppCopyright: " + copyright.Copyright);
|
||||
ConsoleLog("AppProductVersion: " + System.Windows.Forms.Application.ProductVersion);
|
||||
}
|
||||
|
||||
bool autoact = false;
|
||||
bool hiderun = false;
|
||||
bool expact = false;
|
||||
bool showhelp = false;
|
||||
//static bool autoact = false;
|
||||
//static bool hiderun = false;
|
||||
//static bool expact = false;
|
||||
//static bool log2file = false;
|
||||
//static bool showhelp = false;
|
||||
|
||||
//public string SystemEdition = OSVersionInfo.Name + " " + OSVersionInfo.Edition;
|
||||
public string SystemEdition = OSVersionInfo.Edition;
|
||||
|
||||
bool isDark = false;
|
||||
|
||||
string WindowsTheme = "Light";
|
||||
|
||||
NotifyIcon notifyIcon;
|
||||
|
||||
public void CheckWindowsTheme()
|
||||
{
|
||||
var uiSettings = new Windows.UI.ViewManagement.UISettings();
|
||||
Windows.UI.Color Wcolor = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
|
||||
System.Drawing.Color Scolor = System.Drawing.Color.FromArgb(Wcolor.R, Wcolor.G, Wcolor.B);
|
||||
float hue = Scolor.GetHue(); // 色调
|
||||
float saturation = Scolor.GetSaturation(); // 饱和度
|
||||
float lightness = Scolor.GetBrightness(); // 亮度
|
||||
|
||||
if (lightness > 0.75)
|
||||
{
|
||||
isDark = false;
|
||||
WindowsTheme = "Light";
|
||||
}
|
||||
else
|
||||
{
|
||||
isDark = true;
|
||||
WindowsTheme = "Dark";
|
||||
}
|
||||
|
||||
//ConsoleLog("Windows Theme Background is: " + Wcolor);
|
||||
//ConsoleLog("Windows Theme Brightness is: " + lightness);
|
||||
//ConsoleLog("Windows Theme Mode is: " + WindowsTheme);
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
CheckWindowsTheme();
|
||||
|
||||
ConsoleLog("Windows Theme Mode is: " + WindowsTheme);
|
||||
|
||||
GetEdition(); // 获取程序版本
|
||||
|
||||
autoact = Program.autoact;
|
||||
hiderun = Program.hiderun;
|
||||
expact = Program.expact;
|
||||
showhelp = Program.showhelp;
|
||||
//autoact = Program.autoact;
|
||||
//hiderun = Program.hiderun;
|
||||
//expact = Program.expact;
|
||||
//log2file = Program.log2file;
|
||||
//showhelp = Program.showhelp;
|
||||
|
||||
//MessageBox.Show("A:" + autoact.ToString() + ";H:" + hiderun.ToString());
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
ApplyBase(isDark);
|
||||
|
||||
string LangName = currentCultureInfo.Name;
|
||||
//根据本地语言来进行本地化
|
||||
LangName = LangName.Substring(0, LangName.IndexOf("-"));
|
||||
@ -234,7 +327,7 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
//System.Windows.MessageBox.Show((string)this.Resources["HelpText"]);
|
||||
|
||||
if (showhelp == true)
|
||||
if (Program.showhelp == true)
|
||||
{
|
||||
DialogHelp.IsOpen = true;
|
||||
}
|
||||
@ -243,7 +336,7 @@ namespace CMWTAT_DIGITAL
|
||||
notifyIcon.Text = (string)this.Resources["notifyIconTitle"]; //托盘图标标题
|
||||
notifyIcon.Icon = ((System.Drawing.Icon)(CMWTAT_DIGITAL.Properties.Resources.CMWTAT_ICON));
|
||||
|
||||
if ((hiderun == true && autoact == true) || NotSupportLang == true)
|
||||
if ((Program.hiderun == true && Program.autoact == true) || NotSupportLang == true)
|
||||
{
|
||||
|
||||
//notifyIcon.BalloonTipText = "The app has been minimised. Click the tray icon to show.";
|
||||
@ -288,7 +381,7 @@ namespace CMWTAT_DIGITAL
|
||||
notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
|
||||
}
|
||||
|
||||
if (hiderun == true && autoact == true)
|
||||
if (Program.hiderun == true && Program.autoact == true)
|
||||
{
|
||||
this.Hide();
|
||||
|
||||
@ -413,9 +506,9 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("MainServer:" + MainServerDomain + " is not working.");
|
||||
Console.WriteLine("Error Message:" + e.Message);
|
||||
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain);
|
||||
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
|
||||
ConsoleLog("Error Message:" + e.Message);
|
||||
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
|
||||
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=1&ver=3"); // 备用服务器
|
||||
}
|
||||
JObject jsonobj = JObject.Parse(json);
|
||||
@ -509,7 +602,7 @@ namespace CMWTAT_DIGITAL
|
||||
DialogWait.IsOpen = false;
|
||||
}));
|
||||
|
||||
if (autoact == true)//自动激活
|
||||
if (Program.autoact == true)//自动激活
|
||||
{
|
||||
Thread actthread = new Thread(RunAct);
|
||||
switch (is_selected)
|
||||
@ -518,7 +611,7 @@ namespace CMWTAT_DIGITAL
|
||||
actthread.Start();
|
||||
break;
|
||||
case 2: //实验性
|
||||
if (expact == true)
|
||||
if (Program.expact == true)
|
||||
{
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
@ -528,7 +621,7 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hiderun == true)
|
||||
if (Program.hiderun == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -540,7 +633,7 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (hiderun == true)
|
||||
if (Program.hiderun == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -565,7 +658,7 @@ namespace CMWTAT_DIGITAL
|
||||
DialogWithExit.IsOpen = true;
|
||||
}));
|
||||
|
||||
if (hiderun == true && autoact == true)
|
||||
if (Program.hiderun == true && Program.autoact == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -601,7 +694,7 @@ namespace CMWTAT_DIGITAL
|
||||
string outex = "UnknowError";
|
||||
for (int i = 0; i < retry; i++) // 默认重试2次
|
||||
{
|
||||
Console.WriteLine("GetHttpWebRequest Try: " + i.ToString());
|
||||
ConsoleLog("GetHttpWebRequest Try: " + i.ToString());
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(url);
|
||||
@ -625,7 +718,7 @@ namespace CMWTAT_DIGITAL
|
||||
catch (WebException ex)
|
||||
{
|
||||
outex = ex.Message;
|
||||
Console.WriteLine("GetHttpWebRequest Exception: " + ex.Message);
|
||||
ConsoleLog("GetHttpWebRequest Exception: " + ex.Message);
|
||||
if (ex.Status == WebExceptionStatus.Timeout) // 超时重试
|
||||
{
|
||||
continue;
|
||||
@ -665,6 +758,20 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
string slmgr_self = tempfile + "slmgr.vbs";
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFile = slmgr;
|
||||
string targetFile = slmgr_self;
|
||||
bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之
|
||||
ConsoleLog("Copy Start: " + sourceFile + " To " + targetFile);
|
||||
System.IO.File.Copy(sourceFile, targetFile, isrewrite);
|
||||
ConsoleLog("Copy Completed.");
|
||||
}
|
||||
catch (Exception CopyExc)
|
||||
{
|
||||
ConsoleLog("Copy has Exception: " + CopyExc.Message);
|
||||
}
|
||||
|
||||
//旧的位置
|
||||
//string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
|
||||
|
||||
@ -693,9 +800,9 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("MainServer:" + MainServerDomain + " is not working.");
|
||||
Console.WriteLine("Error Message:" + e.Message);
|
||||
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain);
|
||||
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
|
||||
ConsoleLog("Error Message:" + e.Message);
|
||||
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
|
||||
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
|
||||
}
|
||||
JObject jsonobj = JObject.Parse(json);
|
||||
@ -703,7 +810,7 @@ namespace CMWTAT_DIGITAL
|
||||
ositems = (JArray)jsonobj["OS"];
|
||||
key = jsonobj[system]["key"].ToString();
|
||||
sku = jsonobj[system]["sku"].ToString();
|
||||
Console.WriteLine("Edition:" + system + "\r\nKEY:" + key + "\r\nSKU:" + sku);
|
||||
ConsoleLog("Edition:" + system + "\r\nKEY:" + key + "\r\nSKU:" + sku);
|
||||
|
||||
}
|
||||
catch
|
||||
@ -732,7 +839,8 @@ namespace CMWTAT_DIGITAL
|
||||
}));
|
||||
//卸载
|
||||
string runend = RunCScript(slmgr_self, "-upk").Trim();
|
||||
Console.WriteLine(runend);
|
||||
//string runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -upk").Trim();
|
||||
ConsoleLog(runend);
|
||||
if (runend.EndsWith("successfully.") || runend.EndsWith("not found."))
|
||||
{
|
||||
|
||||
@ -743,6 +851,7 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
//安装数字权利升级密钥
|
||||
if (RunCScript(slmgr_self, "-ipk " + key).Trim().EndsWith("successfully."))
|
||||
//if (RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key).Trim().EndsWith("successfully."))
|
||||
{
|
||||
code = "200";
|
||||
}
|
||||
@ -791,7 +900,7 @@ namespace CMWTAT_DIGITAL
|
||||
{
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (hiderun == true && autoact == true)
|
||||
if (Program.hiderun == true && Program.autoact == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -827,6 +936,20 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
string slmgr_self = tempfile + "slmgr.vbs";
|
||||
|
||||
try
|
||||
{
|
||||
string sourceFile = slmgr;
|
||||
string targetFile = slmgr_self;
|
||||
bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之
|
||||
ConsoleLog("Copy Start: " + sourceFile + " To " + targetFile);
|
||||
System.IO.File.Copy(sourceFile, targetFile, isrewrite);
|
||||
ConsoleLog("Copy Completed.");
|
||||
}
|
||||
catch (Exception CopyExc)
|
||||
{
|
||||
ConsoleLog("Copy has Exception: " + CopyExc.Message);
|
||||
}
|
||||
|
||||
//旧的位置
|
||||
//string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
|
||||
|
||||
@ -857,9 +980,9 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("MainServer:" + MainServerDomain + " is not working.");
|
||||
Console.WriteLine("Error Message:" + e.Message);
|
||||
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain);
|
||||
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
|
||||
ConsoleLog("Error Message:" + e.Message);
|
||||
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
|
||||
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
|
||||
}
|
||||
JObject jsonobj = JObject.Parse(json);
|
||||
@ -867,7 +990,7 @@ namespace CMWTAT_DIGITAL
|
||||
ositems = (JArray)jsonobj["OS"];
|
||||
key = jsonobj[system]["key"].ToString();
|
||||
sku = jsonobj[system]["sku"].ToString();
|
||||
Console.WriteLine("Edition:" + system + "\r\nKEY:" + key + "\r\nSKU:" + sku);
|
||||
ConsoleLog("Edition:" + system + "\r\nKEY:" + key + "\r\nSKU:" + sku);
|
||||
|
||||
string selecos = "";
|
||||
// 获取当前选择的选择的文本
|
||||
@ -876,19 +999,19 @@ namespace CMWTAT_DIGITAL
|
||||
selecos = SystemEditionText.Text;
|
||||
}));
|
||||
|
||||
Console.WriteLine("Selected OS: " + selecos);
|
||||
|
||||
if (selecos.ToUpper().StartsWith("(Offline-KMS)".ToUpper()))
|
||||
{
|
||||
Console.WriteLine("Switch Mode Offline-KMS");
|
||||
mode = "4";
|
||||
}
|
||||
ConsoleLog("Selected OS: " + selecos);
|
||||
|
||||
if (sku == "unknow")
|
||||
{
|
||||
mode = "2";
|
||||
}
|
||||
|
||||
if (selecos.ToUpper().StartsWith("(Offline-KMS)".ToUpper()))
|
||||
{
|
||||
ConsoleLog("Switch Mode Offline-KMS");
|
||||
mode = "4";
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -918,12 +1041,23 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
//卸载
|
||||
string runend = RunCScript(slmgr_self, "-upk").Trim();
|
||||
Console.WriteLine(runend);
|
||||
//string runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -upk").Trim();
|
||||
ConsoleLog(runend);
|
||||
if (runend.EndsWith("successfully.") || runend.EndsWith("not found."))
|
||||
{
|
||||
|
||||
RunCScript(slmgr_self, "-ckms").Trim();
|
||||
|
||||
if (mode == "4")
|
||||
{
|
||||
//长期KMS
|
||||
RunCMD(@"sc stop sppsvc");
|
||||
|
||||
RunCMD(@"del /F /Q %systemroot%\system32\spp\store\2.0\tokens.dat");
|
||||
RunCMD(@"del /F /Q %systemroot%\system32\spp\store\2.0\data.dat");
|
||||
RunCMD(@"del /F /Q %systemroot%\system32\spp\store\2.0\cache\cache.dat");
|
||||
}
|
||||
|
||||
if (sku == "unknow")//if (mode == "2" || mode == "3") //获取SKU
|
||||
{
|
||||
|
||||
@ -935,8 +1069,9 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
//安装转换密钥
|
||||
runend = RunCScript(slmgr_self, "-ipk " + key);
|
||||
Console.WriteLine(slmgr_self + " -ipk " + key);
|
||||
Console.WriteLine(runend);
|
||||
//runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key);
|
||||
ConsoleLog(slmgr_self + " -ipk " + key);
|
||||
ConsoleLog(runend);
|
||||
if (runend.Trim().EndsWith("successfully."))
|
||||
{
|
||||
Thread.Sleep(6000); //等待6秒,确保SKU生效
|
||||
@ -950,7 +1085,8 @@ namespace CMWTAT_DIGITAL
|
||||
}));
|
||||
|
||||
runend = RunCScript(slmgr_self, "-upk").Trim();
|
||||
Console.WriteLine(runend);
|
||||
//runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -upk").Trim();
|
||||
ConsoleLog(runend);
|
||||
if (runend.EndsWith("successfully.") || runend.EndsWith("not found."))
|
||||
{
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
@ -987,7 +1123,8 @@ namespace CMWTAT_DIGITAL
|
||||
if (mode == "4")
|
||||
{
|
||||
//长期KMS
|
||||
Console.WriteLine(RunCScript(slmgr_self, "-skms 0.0.0.0").Trim());
|
||||
ConsoleLog(RunCScript(slmgr_self, "-skms 1.1.45.14:1919").Trim()); // いいよ、来いよ www
|
||||
//ConsoleLog(RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -skms 1.1.45.14:1919").Trim()); // いいよ、来いよ www
|
||||
//if (runend.EndsWith("successfully."))
|
||||
//{
|
||||
//}
|
||||
@ -997,6 +1134,7 @@ namespace CMWTAT_DIGITAL
|
||||
{
|
||||
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Retail"" /f");
|
||||
}
|
||||
|
||||
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Kernel-ProductInfo"" /t REG_DWORD /d " + sku + " /f");
|
||||
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Security-SPP-GenuineLocalStatus"" /t REG_DWORD /d 1 /f");
|
||||
RunCMD(@"reg add ""HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\gatherosstate.exe"" /d ""~ WIN7RTM"" /f");
|
||||
@ -1009,8 +1147,9 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
//安装数字权利升级密钥
|
||||
runend = RunCScript(slmgr_self, "-ipk " + key);
|
||||
Console.WriteLine(slmgr_self + " -ipk " + key);
|
||||
Console.WriteLine(runend);
|
||||
//runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key);
|
||||
ConsoleLog(slmgr_self + " -ipk " + key);
|
||||
ConsoleLog(runend);
|
||||
if (runend.Trim().EndsWith("successfully."))
|
||||
{
|
||||
|
||||
@ -1023,32 +1162,36 @@ namespace CMWTAT_DIGITAL
|
||||
if (mode == "4")
|
||||
{
|
||||
//长期KMS
|
||||
RunCMD(tempfile + "gatherosstateltsc.exe");
|
||||
RunCLI(tempfile + "gatherosstateltsc.exe");
|
||||
ConsoleLog("进入下一步");
|
||||
}
|
||||
else
|
||||
{
|
||||
RunCMD(tempfile + "gatherosstate.exe");
|
||||
RunCLI(tempfile + "gatherosstate.exe");
|
||||
ConsoleLog("进入下一步");
|
||||
}
|
||||
|
||||
//旧的位置
|
||||
//RunCMD(System.AppDomain.CurrentDomain.BaseDirectory + "gatherosstate.exe"); tempfile
|
||||
|
||||
for (int i = 0; i < 3 || !File.Exists(tempfile + "GenuineTicket.xml"); i++) //旧的位置: for (int i = 0; i < 3 || !File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"); i++)
|
||||
int try_max_count = 6;
|
||||
for (int i = 0; i < try_max_count + 1 && !File.Exists(tempfile + "GenuineTicket.xml"); i++) //旧的位置: for (int i = 0; i < 3 || !File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"); i++)
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
Thread.Sleep(10000);
|
||||
ConsoleLog($"检查许可证 重试 {i}/{try_max_count}");
|
||||
}
|
||||
|
||||
if (File.Exists(tempfile + "GenuineTicket.xml")) //旧的位置: if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"))
|
||||
{
|
||||
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes";
|
||||
ShowBallSameDig();
|
||||
}));
|
||||
//actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
//{
|
||||
// this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes";
|
||||
// ShowBallSameDig();
|
||||
//}));
|
||||
|
||||
RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f");
|
||||
RunCMD(@"reg delete ""HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\gatherosstate.exe"" /f");
|
||||
//RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f");
|
||||
//RunCMD(@"reg delete ""HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\gatherosstate.exe"" /f");
|
||||
//此处代码移至EndLine
|
||||
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
@ -1056,8 +1199,9 @@ namespace CMWTAT_DIGITAL
|
||||
ShowBallSameDig();
|
||||
}));
|
||||
|
||||
Wow64EnableWow64FsRedirection(false); // 关闭文件重定向
|
||||
RunCMD(Environment.SystemDirectory + @"\ClipUp.exe -v -o -altto " + tempfile);
|
||||
//Wow64EnableWow64FsRedirection(false); // 关闭文件重定向
|
||||
//RunCMD(Environment.SystemDirectory + @"\ClipUp.exe -v -o -altto " + tempfile);
|
||||
RunCMD(@"clipup -v -o -altto " + tempfile);
|
||||
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
@ -1066,7 +1210,8 @@ namespace CMWTAT_DIGITAL
|
||||
}));
|
||||
|
||||
runend = RunCScript(slmgr_self, "-ato").Trim();
|
||||
Console.WriteLine(runend);
|
||||
//runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ato").Trim();
|
||||
ConsoleLog(runend);
|
||||
if (runend.EndsWith("successfully.") || runend.Contains("0xC004F074") || runend.Contains("0xC004C003")) //0xC004F074是KMS(19年)长期激活会出的提示,Error 0xC004C003: The activation server determined that the specified product key is blocked. 是因为未连接激活服务器,下次连接时会自动激活。
|
||||
{
|
||||
if (runend.Contains("0xC004C003"))
|
||||
@ -1100,6 +1245,22 @@ namespace CMWTAT_DIGITAL
|
||||
}
|
||||
//string runend = RunCScript(slmgr_self, "-upk").Trim();
|
||||
EndLine:;
|
||||
// 此处确保注册表清理一定进行
|
||||
try
|
||||
{
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes";
|
||||
ShowBallSameDig();
|
||||
}));
|
||||
|
||||
RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f");
|
||||
RunCMD(@"reg delete ""HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\gatherosstate.exe"" /f");
|
||||
}
|
||||
catch
|
||||
{
|
||||
ConsoleLog("Delete Reg Error");
|
||||
}
|
||||
if (code != "200")
|
||||
{
|
||||
actbtn.Dispatcher.Invoke(new Action(() =>
|
||||
@ -1109,7 +1270,7 @@ namespace CMWTAT_DIGITAL
|
||||
this.DialogWithOKToCloseDialog.IsOpen = true;
|
||||
this.DialogWithOKToCloseDialogTitle.Text = (string)this.Resources["ErrorTitle"]; //错误标题
|
||||
this.DialogWithOKToCloseDialogText.Text = msg + "\r\n" + (string)this.Resources["ErrorCode"] + code; //错误代码 如:错误信息\r\nCode:000
|
||||
if (hiderun == true && autoact == true)
|
||||
if (Program.hiderun == true && Program.autoact == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -1138,7 +1299,7 @@ namespace CMWTAT_DIGITAL
|
||||
this.DialogWithOKToCloseDialogDonateText.Text = (string)this.Resources["DonateTextActivated"]; //完成激活内容
|
||||
}
|
||||
|
||||
if (hiderun == true && autoact == true)
|
||||
if (Program.hiderun == true && Program.autoact == true)
|
||||
{
|
||||
int tipShowMilliseconds = 0;
|
||||
string tipTitle = (string)this.Resources["notifyIconTitle"];
|
||||
@ -1154,7 +1315,7 @@ namespace CMWTAT_DIGITAL
|
||||
//清理文件
|
||||
}
|
||||
|
||||
private void RunCMD(string var)
|
||||
private void RunCMD_old(string var)
|
||||
{
|
||||
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
||||
@ -1167,32 +1328,101 @@ namespace CMWTAT_DIGITAL
|
||||
p.Start();//启动程序
|
||||
//向CMD窗口发送输入信息:
|
||||
p.StandardInput.WriteLine(var);
|
||||
Console.WriteLine(var);
|
||||
ConsoleLog(var);
|
||||
//p.WaitForExit();
|
||||
ConsoleLog(p.StandardOutput.ReadToEnd().Trim());
|
||||
p.Close();
|
||||
|
||||
//Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
//System.Diagnostics.Process.Start(var);
|
||||
}
|
||||
|
||||
public static string RunCScript(string path, string var = "")
|
||||
public static string RunCLI(string path, string var = "")
|
||||
{
|
||||
ConsoleLog(path + " " + var);
|
||||
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
//执行命令行函数
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
|
||||
System.Diagnostics.ProcessStartInfo myProcessStartInfo = new System.Diagnostics.ProcessStartInfo("CScript", "//Nologo \"" + path + "\" " + var);
|
||||
myProcessStartInfo.UseShellExecute = false;
|
||||
myProcessStartInfo.RedirectStandardOutput = true;
|
||||
myProcessStartInfo.CreateNoWindow = true;
|
||||
//myProcessStartInfo.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcessStartInfo.Arguments = "/c " & Commands
|
||||
myProcessStartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
myProcess.StartInfo = myProcessStartInfo;
|
||||
myProcess.StartInfo.FileName = path;//要执行的程序名称
|
||||
myProcess.StartInfo.UseShellExecute = false;
|
||||
myProcess.StartInfo.RedirectStandardInput = true;//可能接受来自调用程序的输入信息
|
||||
myProcess.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
||||
myProcess.StartInfo.CreateNoWindow = true;//不显示程序窗口
|
||||
myProcess.StartInfo.Arguments = var;
|
||||
//myProcess.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcess.Arguments = "/c " & Commands
|
||||
//myProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
myProcess.Start();
|
||||
myProcess.WaitForExit(120 * 1000);
|
||||
myProcess.WaitForExit(60 * 1000);
|
||||
System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
|
||||
string myString = myStreamReader.ReadToEnd();
|
||||
myProcess.Close();
|
||||
return myString;
|
||||
ConsoleLog(myString.Trim());
|
||||
ConsoleLog("执行完毕");
|
||||
return myString.Trim();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public static string RunCMD(string var)
|
||||
{
|
||||
ConsoleLog(var);
|
||||
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
//执行命令行函数
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
|
||||
myProcess.StartInfo.FileName = "cmd.exe";//要执行的程序名称
|
||||
myProcess.StartInfo.UseShellExecute = false;
|
||||
myProcess.StartInfo.RedirectStandardInput = true;//可能接受来自调用程序的输入信息
|
||||
myProcess.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
||||
myProcess.StartInfo.CreateNoWindow = true;//不显示程序窗口
|
||||
myProcess.StartInfo.Arguments = "/c chcp 437 > nul && cmd /c \"" + var + "\"";
|
||||
//myProcess.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcess.Arguments = "/c " & Commands
|
||||
//myProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
myProcess.Start();
|
||||
myProcess.WaitForExit(60 * 1000);
|
||||
System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
|
||||
string myString = myStreamReader.ReadToEnd();
|
||||
myProcess.Close();
|
||||
ConsoleLog(myString.Trim());
|
||||
return myString.Trim();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public static string RunCScript(string path, string var = "")
|
||||
{
|
||||
ConsoleLog("CScript" + " " + "//Nologo \"" + path + "\" " + var);
|
||||
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
//执行命令行函数
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
|
||||
System.Diagnostics.ProcessStartInfo ProcessStartInfo = new System.Diagnostics.ProcessStartInfo("CScript", "//Nologo \"" + path + "\" " + var);
|
||||
ProcessStartInfo.UseShellExecute = false;
|
||||
ProcessStartInfo.RedirectStandardOutput = true;
|
||||
ProcessStartInfo.CreateNoWindow = true;
|
||||
//myProcessStartInfo.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcessStartInfo.Arguments = "/c " & Commands
|
||||
ProcessStartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
myProcess.StartInfo = ProcessStartInfo;
|
||||
myProcess.Start();
|
||||
myProcess.WaitForExit(60 * 1000);
|
||||
System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
|
||||
string myString = myStreamReader.ReadToEnd();
|
||||
myProcess.Close();
|
||||
ConsoleLog(myString.Trim());
|
||||
return myString.Trim();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -1202,27 +1432,28 @@ namespace CMWTAT_DIGITAL
|
||||
|
||||
public static string GetSKU()
|
||||
{
|
||||
ConsoleLog("Geting SKU");
|
||||
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
|
||||
//执行命令行函数
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
||||
p.StartInfo.FileName = "cmd.exe";//要执行的程序名称
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.Arguments = "/c wmic os get OperatingSystemSKU";
|
||||
//myProcessStartInfo.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcessStartInfo.Arguments = "/c " & Commands
|
||||
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
p.Start();
|
||||
p.WaitForExit(120 * 1000);
|
||||
System.IO.StreamReader myStreamReader = p.StandardOutput;
|
||||
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
|
||||
myProcess.StartInfo.FileName = "cmd.exe";//要执行的程序名称
|
||||
myProcess.StartInfo.UseShellExecute = false;
|
||||
myProcess.StartInfo.RedirectStandardOutput = true;
|
||||
myProcess.StartInfo.CreateNoWindow = true;
|
||||
myProcess.StartInfo.Arguments = "/c wmic os get OperatingSystemSKU";
|
||||
//myProcess.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
|
||||
//myProcess.Arguments = "/c " & Commands
|
||||
myProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
myProcess.Start();
|
||||
myProcess.WaitForExit(60 * 1000);
|
||||
System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
|
||||
string myString = myStreamReader.ReadToEnd();
|
||||
p.Close();
|
||||
myProcess.Close();
|
||||
myString = Regex.Replace(myString, @"[^0-9]+", "");
|
||||
Console.WriteLine("Get SKU:\"" + myString + "\"");
|
||||
return myString; //只保留数字SKU
|
||||
ConsoleLog("Get SKU:\"" + myString.Trim() + "\"");
|
||||
return myString.Trim(); //只保留数字SKU
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -1311,5 +1542,11 @@ namespace CMWTAT_DIGITAL
|
||||
{
|
||||
System.Diagnostics.Process.Start("https://cmwtat.cloudmoe.com"); // 打开官网
|
||||
}
|
||||
|
||||
private void Window_Activated(object sender, EventArgs e)
|
||||
{
|
||||
CheckWindowsTheme();
|
||||
ApplyBase(isDark); // 应用颜色
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace CMWTAT_DIGITAL
|
||||
public static bool autoact = false;
|
||||
public static bool hiderun = false;
|
||||
public static bool expact = false;
|
||||
public static bool log2file = false;
|
||||
public static bool showhelp = false;
|
||||
|
||||
/// <summary>
|
||||
@ -27,21 +28,49 @@ namespace CMWTAT_DIGITAL
|
||||
public static void Main(string[] startup_args)
|
||||
{
|
||||
//添加程序集解析事件
|
||||
//AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
|
||||
//{
|
||||
// String resourceName = "CMWTAT_DIGITAL.Res." +
|
||||
|
||||
// new AssemblyName(args.Name).Name + ".dll";
|
||||
|
||||
// Console.WriteLine("Load Assembly: " + resourceName);
|
||||
|
||||
// using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
|
||||
// {
|
||||
// if (stream == null)
|
||||
// return null;
|
||||
|
||||
// Byte[] assemblyData = new Byte[stream.Length];
|
||||
|
||||
// stream.Read(assemblyData, 0, assemblyData.Length);
|
||||
|
||||
// return Assembly.Load(assemblyData);
|
||||
// }
|
||||
//};
|
||||
var loadedAssemblies = new Dictionary<string, Assembly>();
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
|
||||
{
|
||||
String resourceName = "CMWTAT_DIGITAL.Res." +
|
||||
|
||||
new AssemblyName(args.Name).Name + ".dll";
|
||||
|
||||
Console.WriteLine("Load Assembly: " + resourceName);
|
||||
//Must return the EXACT same assembly, do not reload from a new stream
|
||||
if (loadedAssemblies.TryGetValue(resourceName, out Assembly loadedAssembly))
|
||||
{
|
||||
return loadedAssembly;
|
||||
}
|
||||
|
||||
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
|
||||
{
|
||||
if (stream == null)
|
||||
return null;
|
||||
Byte[] assemblyData = new Byte[stream.Length];
|
||||
|
||||
stream.Read(assemblyData, 0, assemblyData.Length);
|
||||
|
||||
return Assembly.Load(assemblyData);
|
||||
var assembly = Assembly.Load(assemblyData);
|
||||
loadedAssemblies[resourceName] = assembly;
|
||||
return assembly;
|
||||
}
|
||||
};
|
||||
|
||||
@ -63,9 +92,14 @@ namespace CMWTAT_DIGITAL
|
||||
Console.WriteLine("EXPACT: True");
|
||||
expact = true;
|
||||
}
|
||||
if (arg == "-l" || arg == "--log")
|
||||
{
|
||||
Console.WriteLine("LOG: True");
|
||||
log2file = true;
|
||||
}
|
||||
if (arg == "-?" || arg == "--help")
|
||||
{
|
||||
Console.WriteLine("EXPACT: True");
|
||||
Console.WriteLine("SHOWHELP: True");
|
||||
showhelp = true;
|
||||
}
|
||||
}
|
||||
|
@ -51,5 +51,5 @@ using System.Windows;
|
||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.0")]
|
||||
[assembly: AssemblyVersion("2.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.5.0.0")]
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
CMWTAT_Digital_Release_2_5_0_0.zip
Normal file
BIN
CMWTAT_Digital_Release_2_5_0_0.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user