diff --git a/WindowsUpgradeService/MainWindow.xaml b/WindowsUpgradeService/MainWindow.xaml index 5989bb8..cd9e190 100644 --- a/WindowsUpgradeService/MainWindow.xaml +++ b/WindowsUpgradeService/MainWindow.xaml @@ -1,12 +1,13 @@ - - - - - + + + + diff --git a/WindowsUpgradeService/MainWindow.xaml.cs b/WindowsUpgradeService/MainWindow.xaml.cs index b6c0d4e..eb93bec 100644 --- a/WindowsUpgradeService/MainWindow.xaml.cs +++ b/WindowsUpgradeService/MainWindow.xaml.cs @@ -1,85 +1,110 @@ -using DiscUtils.Udf; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace WindowsUpgradeService -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - public MainWindow() - { - ExtractISO(); - SetupWindows(); - InitializeComponent(); - } - static string OutPutWork = $"{Environment.GetEnvironmentVariable("SystemDrive")}\\WindowsSetup"; - private void ExtractISO() - { - using (Stream isoStream = File.Open($"{Directory.GetCurrentDirectory()}\\Windows_24H2.iso", FileMode.Open)) - { - UdfReader udfReader = new UdfReader(isoStream); - var DIRcd = udfReader.GetDirectories("\\", "*", SearchOption.AllDirectories); - var FILEScd = udfReader.GetFiles("\\", "*", SearchOption.AllDirectories); - - if (Directory.Exists(OutPutWork)) - { - Directory.Delete(OutPutWork,true); - } - - Directory.CreateDirectory(OutPutWork); - - foreach (var dir in DIRcd) { - Directory.CreateDirectory($"{OutPutWork}{dir}"); - } - - foreach (var files in FILEScd) { - Stream destOutput = File.OpenWrite($"{OutPutWork}{files}"); - Stream fileStream = udfReader.OpenFile(files,FileMode.Open); - fileStream.CopyTo(destOutput); - } - } - } - - private void SetupWindows() - { - var ProcStartInfo = new ProcessStartInfo() - { - FileName = $"{OutPutWork}\\setup.exe", - Arguments = "/auto upgrade /quiet /noreboot", - UseShellExecute = true, - CreateNoWindow = true, - - }; - var ProcStart = new Process() - { - StartInfo = ProcStartInfo, - }; - ProcStart.Start(); - ProcStart.WaitForExit(); - if (ProcStart.ExitCode != 0) { - MessageBox.Show("Failed"); - } else { - MessageBox.Show("Passed"); - - } - - } - } -} +using DiscUtils.Udf; +using Microsoft.Toolkit.Uwp.Notifications; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace WindowsUpgradeService +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + //InitializeComponent(); + ExtractISO(); + SetupWindows(); + } + static string OutPutWork = $"{Environment.GetEnvironmentVariable("SystemDrive")}\\WindowsSetup"; + private void ExtractISO() + { + using (Stream isoStream = File.Open($"{Directory.GetCurrentDirectory()}\\Windows_24H2.iso", FileMode.Open)) + { + UdfReader udfReader = new UdfReader(isoStream); + var DIRcd = udfReader.GetDirectories("\\", "*", SearchOption.AllDirectories); + var FILEScd = udfReader.GetFiles("\\", "*", SearchOption.AllDirectories); + + if (Directory.Exists(OutPutWork)) + { + Directory.Delete(OutPutWork,true); + } + + Directory.CreateDirectory(OutPutWork); + + foreach (var dir in DIRcd) { + Directory.CreateDirectory($"{OutPutWork}{dir}"); + } + + foreach (var files in FILEScd) { + Stream destOutput = File.OpenWrite($"{OutPutWork}{files}"); + Stream fileStream = udfReader.OpenFile(files,FileMode.Open); + fileStream.CopyTo(destOutput); + } + } + } + + private void SetupWindows() + { + var ProcStartInfo = new ProcessStartInfo() + { + FileName = $"{OutPutWork}\\setup.exe", + Arguments = "/auto upgrade /quiet /noreboot", + UseShellExecute = true, + CreateNoWindow = true, + + }; + var ProcStart = new Process() + { + StartInfo = ProcStartInfo, + }; + NotifyMe("The Upgrade is in Progress.", "Please do not shutdown or unplug your PC."); + Window1 window1 = new Window1(); + window1.StatusLabel.Content = "The Upgrade is in Progress."; + window1.Show(); + ProcStart.Start(); + ProcStart.WaitForExit(); + if (ProcStart.ExitCode != 0) { + NotifyMe("The Upgrade Failed.", "Please try to install again later."); + window1.StatusLabel.Content = "The Upgrade Failed."; + } + else { + NotifyMe("Welcome to Windows 11.", "Please restart your machine and allow the setup to complete."); + window1.StatusLabel.Content = "Please restart your machine and allow the setup to complete."; + } + + } + public void NotifyMe(string Title, string Message) + { + new ToastContentBuilder() + .AddArgument("action", "viewConversation") + .AddArgument("conversationId", 6969) + .AddText(Title) + .AddText(Message) + .Show(); + } + private void StatusLabel_Loaded(object sender, RoutedEventArgs e) + { + + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + Visibility = Visibility.Collapsed; + } + } +} diff --git a/WindowsUpgradeService/Window1.xaml b/WindowsUpgradeService/Window1.xaml new file mode 100644 index 0000000..a3f8d08 --- /dev/null +++ b/WindowsUpgradeService/Window1.xaml @@ -0,0 +1,13 @@ + + + + diff --git a/WindowsUpgradeService/Window1.xaml.cs b/WindowsUpgradeService/Window1.xaml.cs new file mode 100644 index 0000000..78e4e13 --- /dev/null +++ b/WindowsUpgradeService/Window1.xaml.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace WindowsUpgradeService +{ + /// + /// Interaction logic for Window1.xaml + /// + public partial class Window1 : Window + { + public Window1() + { + InitializeComponent(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + var desktopWorkingArea = System.Windows.SystemParameters.WorkArea; + this.Left = desktopWorkingArea.Right - this.Width; + this.Top = desktopWorkingArea.Bottom - this.Height; + + } + + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + Environment.Exit(0); + } + } +} diff --git a/WindowsUpgradeService/WindowsUpgradeService.csproj b/WindowsUpgradeService/WindowsUpgradeService.csproj index e3f7463..f33f831 100644 --- a/WindowsUpgradeService/WindowsUpgradeService.csproj +++ b/WindowsUpgradeService/WindowsUpgradeService.csproj @@ -1,194 +1,188 @@ - - - - - Debug - AnyCPU - {70C42B35-5B42-4495-92BE-29A72C9C61FE} - WinExe - WindowsUpgradeService - WindowsUpgradeService - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - x64 - true - embedded - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - app.manifest - - - - ..\packages\LTRData.DiscUtils.Core.1.0.48\lib\net48\DiscUtils.Core.dll - - - ..\packages\LTRData.DiscUtils.Iso9660.1.0.48\lib\net48\DiscUtils.Iso9660.dll - - - ..\packages\LTRData.DiscUtils.Streams.1.0.48\lib\net48\DiscUtils.Streams.dll - - - ..\packages\LTRData.DiscUtils.Udf.1.0.48\lib\net48\DiscUtils.Udf.dll - - - ..\packages\LTRData.Extensions.1.0.13\lib\net48\LTRData.Extensions.dll - - - ..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll - - - - ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - - - - - ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll - True - True - - - ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll - True - True - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll - True - True - - - ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - True - True - - - ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - True - True - - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - False - Microsoft .NET Framework 4.8 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - + + + + + Debug + AnyCPU + {70C42B35-5B42-4495-92BE-29A72C9C61FE} + WinExe + WindowsUpgradeService + WindowsUpgradeService + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + + x64 + true + embedded + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.manifest + + + + ..\packages\LTRData.DiscUtils.Core.1.0.48\lib\net48\DiscUtils.Core.dll + + + ..\packages\LTRData.DiscUtils.Iso9660.1.0.48\lib\net48\DiscUtils.Iso9660.dll + + + ..\packages\LTRData.DiscUtils.Streams.1.0.48\lib\net48\DiscUtils.Streams.dll + + + ..\packages\LTRData.DiscUtils.Udf.1.0.48\lib\net48\DiscUtils.Udf.dll + + + ..\packages\LTRData.Extensions.1.0.13\lib\net48\LTRData.Extensions.dll + + + ..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Window1.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + 1.0.48 + + + 1.0.13 + + + 7.1.3 + + + \ No newline at end of file