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:
TGSAN 2018-12-29 02:28:28 +08:00
parent ce21e6484b
commit b30a728aeb
12 changed files with 415 additions and 132 deletions

View File

@ -67,7 +67,7 @@
</Reference> </Reference>
<Reference Include="MaterialDesignThemes.Wpf, Version=2.5.0.1205, Culture=neutral, processorArchitecture=MSIL"> <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> <HintPath>..\packages\MaterialDesignThemes.2.5.0.1205\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <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> <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -78,6 +78,7 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Runtime" /> <Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices.WindowsRuntime" /> <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.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -161,9 +162,15 @@
<Resource Include="CMWTAT.ico" /> <Resource Include="CMWTAT.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Res\MaterialDesignColors.dll" /> <EmbeddedResource Include="..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll">
<EmbeddedResource Include="Res\MaterialDesignThemes.Wpf.dll" /> <Link>Res\MaterialDesignColors.dll</Link>
<EmbeddedResource Include="Res\Newtonsoft.Json.dll" /> </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>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">

View File

@ -15,7 +15,6 @@
<VerifyUploadedFiles>false</VerifyUploadedFiles> <VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartArguments> <StartArguments>-l -%3f</StartArguments>
</StartArguments>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -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"> <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--> <!--FontFamily Dictionary-->
@ -169,7 +169,7 @@
--> -->
<sys:String x:Key="HelpText" xml:space="preserve"> <sys:String x:Key="HelpText" xml:space="preserve">
This application now supports the use of console args to startup!&#10;&#10;-a&#9;--auto&#9;&#9;Auto activate.&#10;-h&#9;--hide&#9;&#9;Run with hide mode (Only be worked with -auto).&#10;-e&#9;--expact&#9;&#9;Experimental activation.&#10;-?&#9;--help&#9;&#9;Show this help Dialog. This application now supports the use of console args to startup!&#10;&#10;-a&#9;--auto&#9;&#9;Auto activate.&#10;-h&#9;--hide&#9;&#9;Run with hide mode (Only be worked with -auto).&#10;-e&#9;--expact&#9;&#9;Experimental activation.&#10;-l&#9;--log&#9;&#9;Output log to file.&#10;-?&#9;--help&#9;&#9;Show this help Dialog.
</sys:String> </sys:String>
<sys:String x:Key="DonateTextConverted" xml:space="preserve"> <sys:String x:Key="DonateTextConverted" xml:space="preserve">
Congratulation! &#10;&#10;Windows 10 has been successful converted. Congratulation! &#10;&#10;Windows 10 has been successful converted.

View File

@ -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"> <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--> <!--FontFamily Dictionary-->
@ -169,7 +169,7 @@
--> -->
<sys:String x:Key="HelpText" xml:space="preserve"> <sys:String x:Key="HelpText" xml:space="preserve">
このアプリは起動時にコンソール引数を使用できるようになりました!&#10;&#10;-a&#9;--auto&#9;&#9;自動認証。&#10;-h&#9;--hide&#9;&#9;非表示モードで実行 (-autoと一緒に使用するだけ可能)。&#10;-e&#9;--expact&#9;&#9;実験性認証。&#10;-?&#9;--help&#9;&#9;この説明ダイアログボックスを表示する。 このアプリは起動時にコンソール引数を使用できるようになりました!&#10;&#10;-a&#9;--auto&#9;&#9;自動認証。&#10;-h&#9;--hide&#9;&#9;非表示モードで実行 (-autoと一緒に使用するだけ可能)。&#10;-e&#9;--expact&#9;&#9;実験性認証。&#10;-l&#9;--log&#9;&#9;ログをファイルに出力。&#10;-?&#9;--help&#9;&#9;この説明ダイアログボックスを表示する。
</sys:String> </sys:String>
<sys:String x:Key="DonateTextConverted" xml:space="preserve"> <sys:String x:Key="DonateTextConverted" xml:space="preserve">
おめでとう! &#10;&#10;Windows 10 エディション変換成功。 おめでとう! &#10;&#10;Windows 10 エディション変換成功。
@ -205,9 +205,9 @@ Windows10ライセンス認証にはインターネットを通じてキーを
認証失敗。 :( &#10;多分: &#10;1. このエディション/バージョンの Windows はデジタルライセンス認証が適用しない。 &#10;2. マイクロソフトの認証サーバーに接続できません。 &#10;3. その他。 &#10;&#10;暫くお待ちくださいまたはあとでもう一度やり直してください。 &#10; 認証失敗。 :( &#10;多分: &#10;1. このエディション/バージョンの Windows はデジタルライセンス認証が適用しない。 &#10;2. マイクロソフトの認証サーバーに接続できません。 &#10;3. その他。 &#10;&#10;暫くお待ちくださいまたはあとでもう一度やり直してください。 &#10;
</sys:String> </sys:String>
<sys:String x:Key="Only_find_ltok" xml:space="preserve"> <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. &#10;This means that it will not be activate automatically after you reinstalled the system. &#10;But don't worry, this is different from the legacy KMS activation method (it can keep activating for 180 days in offline environment). &#10;LTOK (The prefix is Offline-KMS) can keep activating for up to 19 years even it is without networking! このシステムエディションに適用されたのは長期オフラインKMS(LTOK)オプションしか見つかりません。これによってシステムを再インストールした時自動的にライセンス認証しませんが、心配する必要はありません。この方法(LTOK)でライセンス認証後、インターネット接続なしでも最大19年間稼働を継続できます!
</sys:String> </sys:String>
<sys:String x:Key="DonateTextWillActivated" xml:space="preserve"> <sys:String x:Key="DonateTextWillActivated" xml:space="preserve">
Congratulation! &#10;&#10;Windows 10 is ready to activate. &#10;However, it seems that Windows cannot connect to the Microsoft Activation Server.&#10;Your system will be activated automatically the next time the server is connected. おめでとうございます! &#10;&#10;Windows 10はライセンス認証の準備が出来ています。&#10;でも、マイクロソフトのライセンス認証サーバーに接続できませんみたいです。&#10;システムは認証サーバーに接続出来る次第に自動的にライセンス認証します。
</sys:String> </sys:String>
</ResourceDictionary> </ResourceDictionary>

View File

@ -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"> <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--> <!--FontFamily Dictionary-->
@ -169,7 +169,7 @@
--> -->
<sys:String x:Key="HelpText" xml:space="preserve"> <sys:String x:Key="HelpText" xml:space="preserve">
这个应用现已支持通过控制台参数启动!&#10;&#10;-a&#9;--auto&#9;&#9;自动激活。&#10;-h&#9;--hide&#9;&#9;隐藏模式运行 (只能与 -auto 一起使用)。&#10;-e&#9;--expact&#9;&#9;实验性激活。&#10;-?&#9;--help&#9;&#9;显示此说明对话框。 这个应用现已支持通过控制台参数启动!&#10;&#10;-a&#9;--auto&#9;&#9;自动激活。&#10;-h&#9;--hide&#9;&#9;隐藏模式运行 (只能与 -auto 一起使用)。&#10;-e&#9;--expact&#9;实验性激活。&#10;-l&#9;--log&#9;&#9;输出日志到文件。&#10;-?&#9;--help&#9;&#9;显示此说明对话框。
</sys:String> </sys:String>
<sys:String x:Key="DonateTextConverted" xml:space="preserve"> <sys:String x:Key="DonateTextConverted" xml:space="preserve">
祝贺! &#10;&#10;Windows 10 已经成功转换。 祝贺! &#10;&#10;Windows 10 已经成功转换。

View File

@ -19,15 +19,17 @@
Icon="CMWTAT.ico" Icon="CMWTAT.ico"
Closing="Window_Closing" Closing="Window_Closing"
FontFamily="{DynamicResource Font}" FontFamily="{DynamicResource Font}"
Activated="Window_Activated"
WindowStartupLocation="CenterScreen"
> >
<!--FontFamily="{DynamicResource MaterialDesignFont}"--> <!--FontFamily="{DynamicResource MaterialDesignFont}"-->
<Grid> <Grid>
<Grid Margin="30,30,30,30" VerticalAlignment="Center"> <Grid Margin="30,30,30,30" VerticalAlignment="Center">
<StackPanel> <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> <TextBlock FontFamily="{DynamicResource Font}" Style="{DynamicResource MaterialDesignTitleTextBlock}" ><Run Text="{DynamicResource AppName}"/></TextBlock>
</materialDesign:Card> </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> <StackPanel>
<Grid> <Grid>
<ComboBox x:Name="SystemEditionText" DisplayMemberPath="DisplayOS" VerticalAlignment="Center" Visibility="Visible"/> <ComboBox x:Name="SystemEditionText" DisplayMemberPath="DisplayOS" VerticalAlignment="Center" Visibility="Visible"/>
@ -48,15 +50,19 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</materialDesign:Card> </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"/> <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}" Margin="0,30,0,0" VerticalAlignment="Top" Click="installbtn_Click" Height="65"/> <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> </StackPanel>
</Grid> </Grid>
<Grid x:Name="DialogHostGrid" Visibility="Hidden"> <Grid x:Name="DialogHostGrid" Visibility="Hidden">
<materialDesign:DialogHost x:Name="DialogWait" IsOpen="False"> <materialDesign:DialogHost x:Name="DialogWait" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="32,24,32,24"> <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" /> <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 x:Name="DialogActProg" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="32,24,32,24"> <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" /> <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 x:Name="DialogWithCancel" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="24,24,24,8"> <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" /> <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 x:Name="DialogWithOK" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<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 x:Name="DialogHelp" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<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 x:Name="DialogWithExit" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<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 x:Name="DialogWithOKToCloseDialog" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<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 x:Name="DialogWithOKToCloseDialogDonate" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<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 x:Name="DialogUpdate" IsOpen="False">
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<Grid> <Grid>
<materialDesign:Card> <materialDesign:Card UniformCornerRadius="8" materialDesign:ShadowAssist.ShadowDepth="Depth3">
<StackPanel> <StackPanel>
<StackPanel Margin="16,16,16,8"> <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" />--> <!--<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="0,0,0,0" IsIndeterminate="True" Value="0" VerticalAlignment="Top" Width="32" Height="32" />-->

View File

@ -24,6 +24,7 @@ using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using MaterialDesignThemes.Wpf;
namespace CMWTAT_DIGITAL namespace CMWTAT_DIGITAL
{ {
@ -47,6 +48,42 @@ namespace CMWTAT_DIGITAL
public string DisplayOS { get; set; } 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\"; string tempfile = System.IO.Path.GetTempPath() + @"CMWTAT_DIGITAL\";
public void DelectTempFile() public void DelectTempFile()
@ -73,7 +110,9 @@ namespace CMWTAT_DIGITAL
FileAttributes attr = File.GetAttributes(tempfile); FileAttributes attr = File.GetAttributes(tempfile);
if (attr == FileAttributes.Directory) if (attr == FileAttributes.Directory)
{ {
Directory.Delete(tempfile, true); Directory.Delete(tempfile, true);
} }
else else
{ {
@ -82,7 +121,7 @@ namespace CMWTAT_DIGITAL
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("DelectTempFile:" + e.Message); ConsoleLog("DelectTempFile:" + e.Message);
} }
} }
} }
@ -99,12 +138,24 @@ namespace CMWTAT_DIGITAL
if (Directory.Exists(tempfile)) if (Directory.Exists(tempfile))
{ {
ConsoleLog("找到已存在的缓存,开始删除");
DelectTempFile(); DelectTempFile();
} else ConsoleLog("删除操作完毕");
{ if (Directory.Exists(tempfile))
Directory.CreateDirectory(tempfile); {
ConsoleLog("检测到文件依旧存在,等待三秒");
Thread.Sleep(3000);
}
else
{
ConsoleLog("确认完毕");
}
} }
ConsoleLog("开始创建缓存");
Directory.CreateDirectory(tempfile);
ConsoleLog("创建缓存完毕");
byte[] temp; byte[] temp;
System.IO.FileStream fileStream; 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"; // 存储程序版本 string ProductVersion = "0.0.0.0"; // 存储程序版本
/// <summary> /// <summary>
@ -183,7 +239,7 @@ namespace CMWTAT_DIGITAL
{ {
Assembly assembly = Assembly.GetExecutingAssembly(); Assembly assembly = Assembly.GetExecutingAssembly();
Console.WriteLine("AppAssemblyFullName: " + assembly.FullName); ConsoleLog("AppAssemblyFullName: " + assembly.FullName);
// 获取程序集元数据 // 获取程序集元数据
AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)
@ -195,35 +251,72 @@ namespace CMWTAT_DIGITAL
ProductVersion = System.Windows.Forms.Application.ProductVersion; ProductVersion = System.Windows.Forms.Application.ProductVersion;
Console.WriteLine("AppDescription: " + description.Description); ConsoleLog("AppDescription: " + description.Description);
Console.WriteLine("AppCopyright: " + copyright.Copyright); ConsoleLog("AppCopyright: " + copyright.Copyright);
Console.WriteLine("AppProductVersion: " + System.Windows.Forms.Application.ProductVersion); ConsoleLog("AppProductVersion: " + System.Windows.Forms.Application.ProductVersion);
} }
bool autoact = false; //static bool autoact = false;
bool hiderun = false; //static bool hiderun = false;
bool expact = false; //static bool expact = false;
bool showhelp = false; //static bool log2file = false;
//static bool showhelp = false;
//public string SystemEdition = OSVersionInfo.Name + " " + OSVersionInfo.Edition; //public string SystemEdition = OSVersionInfo.Name + " " + OSVersionInfo.Edition;
public string SystemEdition = OSVersionInfo.Edition; public string SystemEdition = OSVersionInfo.Edition;
bool isDark = false;
string WindowsTheme = "Light";
NotifyIcon notifyIcon; 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() public MainWindow()
{ {
CheckWindowsTheme();
ConsoleLog("Windows Theme Mode is: " + WindowsTheme);
GetEdition(); // 获取程序版本 GetEdition(); // 获取程序版本
autoact = Program.autoact; //autoact = Program.autoact;
hiderun = Program.hiderun; //hiderun = Program.hiderun;
expact = Program.expact; //expact = Program.expact;
showhelp = Program.showhelp; //log2file = Program.log2file;
//showhelp = Program.showhelp;
//MessageBox.Show("A:" + autoact.ToString() + ";H:" + hiderun.ToString()); //MessageBox.Show("A:" + autoact.ToString() + ";H:" + hiderun.ToString());
InitializeComponent(); InitializeComponent();
ApplyBase(isDark);
string LangName = currentCultureInfo.Name; string LangName = currentCultureInfo.Name;
//根据本地语言来进行本地化 //根据本地语言来进行本地化
LangName = LangName.Substring(0, LangName.IndexOf("-")); LangName = LangName.Substring(0, LangName.IndexOf("-"));
@ -234,7 +327,7 @@ namespace CMWTAT_DIGITAL
//System.Windows.MessageBox.Show((string)this.Resources["HelpText"]); //System.Windows.MessageBox.Show((string)this.Resources["HelpText"]);
if (showhelp == true) if (Program.showhelp == true)
{ {
DialogHelp.IsOpen = true; DialogHelp.IsOpen = true;
} }
@ -243,7 +336,7 @@ namespace CMWTAT_DIGITAL
notifyIcon.Text = (string)this.Resources["notifyIconTitle"]; //托盘图标标题 notifyIcon.Text = (string)this.Resources["notifyIconTitle"]; //托盘图标标题
notifyIcon.Icon = ((System.Drawing.Icon)(CMWTAT_DIGITAL.Properties.Resources.CMWTAT_ICON)); 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."; //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); notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
} }
if (hiderun == true && autoact == true) if (Program.hiderun == true && Program.autoact == true)
{ {
this.Hide(); this.Hide();
@ -413,9 +506,9 @@ namespace CMWTAT_DIGITAL
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("MainServer:" + MainServerDomain + " is not working."); ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
Console.WriteLine("Error Message:" + e.Message); ConsoleLog("Error Message:" + e.Message);
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain); ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=1&ver=3"); // 备用服务器 json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=1&ver=3"); // 备用服务器
} }
JObject jsonobj = JObject.Parse(json); JObject jsonobj = JObject.Parse(json);
@ -509,7 +602,7 @@ namespace CMWTAT_DIGITAL
DialogWait.IsOpen = false; DialogWait.IsOpen = false;
})); }));
if (autoact == true)//自动激活 if (Program.autoact == true)//自动激活
{ {
Thread actthread = new Thread(RunAct); Thread actthread = new Thread(RunAct);
switch (is_selected) switch (is_selected)
@ -518,7 +611,7 @@ namespace CMWTAT_DIGITAL
actthread.Start(); actthread.Start();
break; break;
case 2: //实验性 case 2: //实验性
if (expact == true) if (Program.expact == true)
{ {
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
{ {
@ -528,7 +621,7 @@ namespace CMWTAT_DIGITAL
} }
else else
{ {
if (hiderun == true) if (Program.hiderun == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; string tipTitle = (string)this.Resources["notifyIconTitle"];
@ -540,7 +633,7 @@ namespace CMWTAT_DIGITAL
} }
break; break;
default: default:
if (hiderun == true) if (Program.hiderun == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; string tipTitle = (string)this.Resources["notifyIconTitle"];
@ -565,7 +658,7 @@ namespace CMWTAT_DIGITAL
DialogWithExit.IsOpen = true; DialogWithExit.IsOpen = true;
})); }));
if (hiderun == true && autoact == true) if (Program.hiderun == true && Program.autoact == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; string tipTitle = (string)this.Resources["notifyIconTitle"];
@ -601,7 +694,7 @@ namespace CMWTAT_DIGITAL
string outex = "UnknowError"; string outex = "UnknowError";
for (int i = 0; i < retry; i++) // 默认重试2次 for (int i = 0; i < retry; i++) // 默认重试2次
{ {
Console.WriteLine("GetHttpWebRequest Try: " + i.ToString()); ConsoleLog("GetHttpWebRequest Try: " + i.ToString());
try try
{ {
Uri uri = new Uri(url); Uri uri = new Uri(url);
@ -625,7 +718,7 @@ namespace CMWTAT_DIGITAL
catch (WebException ex) catch (WebException ex)
{ {
outex = ex.Message; outex = ex.Message;
Console.WriteLine("GetHttpWebRequest Exception: " + ex.Message); ConsoleLog("GetHttpWebRequest Exception: " + ex.Message);
if (ex.Status == WebExceptionStatus.Timeout) // 超时重试 if (ex.Status == WebExceptionStatus.Timeout) // 超时重试
{ {
continue; continue;
@ -665,6 +758,20 @@ namespace CMWTAT_DIGITAL
string slmgr_self = tempfile + "slmgr.vbs"; 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"; //string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
@ -693,9 +800,9 @@ namespace CMWTAT_DIGITAL
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("MainServer:" + MainServerDomain + " is not working."); ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
Console.WriteLine("Error Message:" + e.Message); ConsoleLog("Error Message:" + e.Message);
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain); ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器 json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
} }
JObject jsonobj = JObject.Parse(json); JObject jsonobj = JObject.Parse(json);
@ -703,7 +810,7 @@ namespace CMWTAT_DIGITAL
ositems = (JArray)jsonobj["OS"]; ositems = (JArray)jsonobj["OS"];
key = jsonobj[system]["key"].ToString(); key = jsonobj[system]["key"].ToString();
sku = jsonobj[system]["sku"].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 catch
@ -732,7 +839,8 @@ namespace CMWTAT_DIGITAL
})); }));
//卸载 //卸载
string runend = RunCScript(slmgr_self, "-upk").Trim(); 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.")) 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 (RunCScript(slmgr_self, "-ipk " + key).Trim().EndsWith("successfully."))
//if (RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key).Trim().EndsWith("successfully."))
{ {
code = "200"; code = "200";
} }
@ -791,7 +900,7 @@ namespace CMWTAT_DIGITAL
{ {
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
{ {
if (hiderun == true && autoact == true) if (Program.hiderun == true && Program.autoact == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; string tipTitle = (string)this.Resources["notifyIconTitle"];
@ -827,6 +936,20 @@ namespace CMWTAT_DIGITAL
string slmgr_self = tempfile + "slmgr.vbs"; 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"; //string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
@ -857,9 +980,9 @@ namespace CMWTAT_DIGITAL
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine("MainServer:" + MainServerDomain + " is not working."); ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
Console.WriteLine("Error Message:" + e.Message); ConsoleLog("Error Message:" + e.Message);
Console.WriteLine("Ready to use BackupServer:" + BackupServerDomain); ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器 json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
} }
JObject jsonobj = JObject.Parse(json); JObject jsonobj = JObject.Parse(json);
@ -867,7 +990,7 @@ namespace CMWTAT_DIGITAL
ositems = (JArray)jsonobj["OS"]; ositems = (JArray)jsonobj["OS"];
key = jsonobj[system]["key"].ToString(); key = jsonobj[system]["key"].ToString();
sku = jsonobj[system]["sku"].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 = ""; string selecos = "";
// 获取当前选择的选择的文本 // 获取当前选择的选择的文本
@ -876,19 +999,19 @@ namespace CMWTAT_DIGITAL
selecos = SystemEditionText.Text; selecos = SystemEditionText.Text;
})); }));
Console.WriteLine("Selected OS: " + selecos); ConsoleLog("Selected OS: " + selecos);
if (selecos.ToUpper().StartsWith("(Offline-KMS)".ToUpper()))
{
Console.WriteLine("Switch Mode Offline-KMS");
mode = "4";
}
if (sku == "unknow") if (sku == "unknow")
{ {
mode = "2"; mode = "2";
} }
if (selecos.ToUpper().StartsWith("(Offline-KMS)".ToUpper()))
{
ConsoleLog("Switch Mode Offline-KMS");
mode = "4";
}
} }
catch catch
{ {
@ -918,12 +1041,23 @@ namespace CMWTAT_DIGITAL
//卸载 //卸载
string runend = RunCScript(slmgr_self, "-upk").Trim(); 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.")) if (runend.EndsWith("successfully.") || runend.EndsWith("not found."))
{ {
RunCScript(slmgr_self, "-ckms").Trim(); 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 if (sku == "unknow")//if (mode == "2" || mode == "3") //获取SKU
{ {
@ -935,8 +1069,9 @@ namespace CMWTAT_DIGITAL
//安装转换密钥 //安装转换密钥
runend = RunCScript(slmgr_self, "-ipk " + key); runend = RunCScript(slmgr_self, "-ipk " + key);
Console.WriteLine(slmgr_self + " -ipk " + key); //runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key);
Console.WriteLine(runend); ConsoleLog(slmgr_self + " -ipk " + key);
ConsoleLog(runend);
if (runend.Trim().EndsWith("successfully.")) if (runend.Trim().EndsWith("successfully."))
{ {
Thread.Sleep(6000); //等待6秒确保SKU生效 Thread.Sleep(6000); //等待6秒确保SKU生效
@ -950,7 +1085,8 @@ namespace CMWTAT_DIGITAL
})); }));
runend = RunCScript(slmgr_self, "-upk").Trim(); 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.")) if (runend.EndsWith("successfully.") || runend.EndsWith("not found."))
{ {
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
@ -987,7 +1123,8 @@ namespace CMWTAT_DIGITAL
if (mode == "4") if (mode == "4")
{ {
//长期KMS //长期KMS
Console.WriteLine(RunCScript(slmgr_self, "-skms 0.0.0.0").Trim()); ConsoleLog(RunCScript(slmgr_self, "-skms 1.1.45.14:1919").Trim()); // いいよ、来いよ
//ConsoleLog(RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -skms 1.1.45.14:1919").Trim()); // いいよ、来いよ
//if (runend.EndsWith("successfully.")) //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"" /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 ""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\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"); 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); runend = RunCScript(slmgr_self, "-ipk " + key);
Console.WriteLine(slmgr_self + " -ipk " + key); //runend = RunCMD(@"cscript.exe /nologo %systemroot%\system32\slmgr.vbs -ipk " + key);
Console.WriteLine(runend); ConsoleLog(slmgr_self + " -ipk " + key);
ConsoleLog(runend);
if (runend.Trim().EndsWith("successfully.")) if (runend.Trim().EndsWith("successfully."))
{ {
@ -1023,32 +1162,36 @@ namespace CMWTAT_DIGITAL
if (mode == "4") if (mode == "4")
{ {
//长期KMS //长期KMS
RunCMD(tempfile + "gatherosstateltsc.exe"); RunCLI(tempfile + "gatherosstateltsc.exe");
ConsoleLog("进入下一步");
} }
else else
{ {
RunCMD(tempfile + "gatherosstate.exe"); RunCLI(tempfile + "gatherosstate.exe");
ConsoleLog("进入下一步");
} }
//旧的位置 //旧的位置
//RunCMD(System.AppDomain.CurrentDomain.BaseDirectory + "gatherosstate.exe"); tempfile //RunCMD(System.AppDomain.CurrentDomain.BaseDirectory + "gatherosstate.exe"); tempfile
int try_max_count = 6;
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++) 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")) if (File.Exists(tempfile + "GenuineTicket.xml")) //旧的位置: if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"))
{ {
actbtn.Dispatcher.Invoke(new Action(() => //actbtn.Dispatcher.Invoke(new Action(() =>
{ //{
this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes"; // this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes";
ShowBallSameDig(); // ShowBallSameDig();
})); //}));
RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f"); //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\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""C:\gatherosstate.exe"" /f");
//此处代码移至EndLine
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
{ {
@ -1056,8 +1199,9 @@ namespace CMWTAT_DIGITAL
ShowBallSameDig(); ShowBallSameDig();
})); }));
Wow64EnableWow64FsRedirection(false); // 关闭文件重定向 //Wow64EnableWow64FsRedirection(false); // 关闭文件重定向
RunCMD(Environment.SystemDirectory + @"\ClipUp.exe -v -o -altto " + tempfile); //RunCMD(Environment.SystemDirectory + @"\ClipUp.exe -v -o -altto " + tempfile);
RunCMD(@"clipup -v -o -altto " + tempfile);
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
{ {
@ -1066,7 +1210,8 @@ namespace CMWTAT_DIGITAL
})); }));
runend = RunCScript(slmgr_self, "-ato").Trim(); 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是KMS19年长期激活会出的提示Error 0xC004C003: The activation server determined that the specified product key is blocked. 是因为未连接激活服务器,下次连接时会自动激活。 if (runend.EndsWith("successfully.") || runend.Contains("0xC004F074") || runend.Contains("0xC004C003")) //0xC004F074是KMS19年长期激活会出的提示Error 0xC004C003: The activation server determined that the specified product key is blocked. 是因为未连接激活服务器,下次连接时会自动激活。
{ {
if (runend.Contains("0xC004C003")) if (runend.Contains("0xC004C003"))
@ -1100,6 +1245,22 @@ namespace CMWTAT_DIGITAL
} }
//string runend = RunCScript(slmgr_self, "-upk").Trim(); //string runend = RunCScript(slmgr_self, "-upk").Trim();
EndLine:; 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") if (code != "200")
{ {
actbtn.Dispatcher.Invoke(new Action(() => actbtn.Dispatcher.Invoke(new Action(() =>
@ -1109,7 +1270,7 @@ namespace CMWTAT_DIGITAL
this.DialogWithOKToCloseDialog.IsOpen = true; this.DialogWithOKToCloseDialog.IsOpen = true;
this.DialogWithOKToCloseDialogTitle.Text = (string)this.Resources["ErrorTitle"]; //错误标题 this.DialogWithOKToCloseDialogTitle.Text = (string)this.Resources["ErrorTitle"]; //错误标题
this.DialogWithOKToCloseDialogText.Text = msg + "\r\n" + (string)this.Resources["ErrorCode"] + code; //错误代码 如:错误信息\r\nCode000 this.DialogWithOKToCloseDialogText.Text = msg + "\r\n" + (string)this.Resources["ErrorCode"] + code; //错误代码 如:错误信息\r\nCode000
if (hiderun == true && autoact == true) if (Program.hiderun == true && Program.autoact == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; string tipTitle = (string)this.Resources["notifyIconTitle"];
@ -1138,7 +1299,7 @@ namespace CMWTAT_DIGITAL
this.DialogWithOKToCloseDialogDonateText.Text = (string)this.Resources["DonateTextActivated"]; //完成激活内容 this.DialogWithOKToCloseDialogDonateText.Text = (string)this.Resources["DonateTextActivated"]; //完成激活内容
} }
if (hiderun == true && autoact == true) if (Program.hiderun == true && Program.autoact == true)
{ {
int tipShowMilliseconds = 0; int tipShowMilliseconds = 0;
string tipTitle = (string)this.Resources["notifyIconTitle"]; 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);//关闭文件重定向 Wow64EnableWow64FsRedirection(false);//关闭文件重定向
System.Diagnostics.Process p = new System.Diagnostics.Process(); System.Diagnostics.Process p = new System.Diagnostics.Process();
@ -1167,32 +1328,101 @@ namespace CMWTAT_DIGITAL
p.Start();//启动程序 p.Start();//启动程序
//向CMD窗口发送输入信息 //向CMD窗口发送输入信息
p.StandardInput.WriteLine(var); p.StandardInput.WriteLine(var);
Console.WriteLine(var); ConsoleLog(var);
//p.WaitForExit();
ConsoleLog(p.StandardOutput.ReadToEnd().Trim());
p.Close();
//Wow64EnableWow64FsRedirection(false);//关闭文件重定向 //Wow64EnableWow64FsRedirection(false);//关闭文件重定向
//System.Diagnostics.Process.Start(var); //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);//关闭文件重定向 Wow64EnableWow64FsRedirection(false);//关闭文件重定向
//执行命令行函数 //执行命令行函数
try try
{ {
System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo myProcessStartInfo = new System.Diagnostics.ProcessStartInfo("CScript", "//Nologo \"" + path + "\" " + var); myProcess.StartInfo.FileName = path;//要执行的程序名称
myProcessStartInfo.UseShellExecute = false; myProcess.StartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true; myProcess.StartInfo.RedirectStandardInput = true;//可能接受来自调用程序的输入信息
myProcessStartInfo.CreateNoWindow = true; myProcess.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
//myProcessStartInfo.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var; myProcess.StartInfo.CreateNoWindow = true;//不显示程序窗口
//myProcessStartInfo.Arguments = "/c " & Commands myProcess.StartInfo.Arguments = var;
myProcessStartInfo.StandardOutputEncoding = Encoding.UTF8; //myProcess.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
myProcess.StartInfo = myProcessStartInfo; //myProcess.Arguments = "/c " & Commands
//myProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;
myProcess.Start(); myProcess.Start();
myProcess.WaitForExit(120 * 1000); myProcess.WaitForExit(60 * 1000);
System.IO.StreamReader myStreamReader = myProcess.StandardOutput; System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
string myString = myStreamReader.ReadToEnd(); string myString = myStreamReader.ReadToEnd();
myProcess.Close(); 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 catch
{ {
@ -1202,27 +1432,28 @@ namespace CMWTAT_DIGITAL
public static string GetSKU() public static string GetSKU()
{ {
ConsoleLog("Geting SKU");
Wow64EnableWow64FsRedirection(false);//关闭文件重定向 Wow64EnableWow64FsRedirection(false);//关闭文件重定向
//执行命令行函数 //执行命令行函数
try try
{ {
System.Diagnostics.Process p = new System.Diagnostics.Process(); System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";//要执行的程序名称 myProcess.StartInfo.FileName = "cmd.exe";//要执行的程序名称
p.StartInfo.UseShellExecute = false; myProcess.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true; myProcess.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true; myProcess.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = "/c wmic os get OperatingSystemSKU"; myProcess.StartInfo.Arguments = "/c wmic os get OperatingSystemSKU";
//myProcessStartInfo.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var; //myProcess.Arguments = "/c chcp 65001 > nul && cmd /c \"" + PHPRuntimePath + "\" \"" + path + "\" " + var;
//myProcessStartInfo.Arguments = "/c " & Commands //myProcess.Arguments = "/c " & Commands
p.StartInfo.StandardOutputEncoding = Encoding.UTF8; myProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start(); myProcess.Start();
p.WaitForExit(120 * 1000); myProcess.WaitForExit(60 * 1000);
System.IO.StreamReader myStreamReader = p.StandardOutput; System.IO.StreamReader myStreamReader = myProcess.StandardOutput;
string myString = myStreamReader.ReadToEnd(); string myString = myStreamReader.ReadToEnd();
p.Close(); myProcess.Close();
myString = Regex.Replace(myString, @"[^0-9]+", ""); myString = Regex.Replace(myString, @"[^0-9]+", "");
Console.WriteLine("Get SKU:\"" + myString + "\""); ConsoleLog("Get SKU:\"" + myString.Trim() + "\"");
return myString; //只保留数字SKU return myString.Trim(); //只保留数字SKU
} }
catch catch
{ {
@ -1311,5 +1542,11 @@ namespace CMWTAT_DIGITAL
{ {
System.Diagnostics.Process.Start("https://cmwtat.cloudmoe.com"); // 打开官网 System.Diagnostics.Process.Start("https://cmwtat.cloudmoe.com"); // 打开官网
} }
private void Window_Activated(object sender, EventArgs e)
{
CheckWindowsTheme();
ApplyBase(isDark); // 应用颜色
}
} }
} }

View File

@ -15,6 +15,7 @@ namespace CMWTAT_DIGITAL
public static bool autoact = false; public static bool autoact = false;
public static bool hiderun = false; public static bool hiderun = false;
public static bool expact = false; public static bool expact = false;
public static bool log2file = false;
public static bool showhelp = false; public static bool showhelp = false;
/// <summary> /// <summary>
@ -27,21 +28,49 @@ namespace CMWTAT_DIGITAL
public static void Main(string[] startup_args) 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) => AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{ {
String resourceName = "CMWTAT_DIGITAL.Res." + String resourceName = "CMWTAT_DIGITAL.Res." +
new AssemblyName(args.Name).Name + ".dll"; 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)) using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{ {
if (stream == null)
return null;
Byte[] assemblyData = new Byte[stream.Length]; Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.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"); Console.WriteLine("EXPACT: True");
expact = true; expact = true;
} }
if (arg == "-l" || arg == "--log")
{
Console.WriteLine("LOG: True");
log2file = true;
}
if (arg == "-?" || arg == "--help") if (arg == "-?" || arg == "--help")
{ {
Console.WriteLine("EXPACT: True"); Console.WriteLine("SHOWHELP: True");
showhelp = true; showhelp = true;
} }
} }

View File

@ -51,5 +51,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: : // 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.0.0")] [assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")] [assembly: AssemblyFileVersion("2.5.0.0")]

Binary file not shown.

Binary file not shown.