diff --git a/MicroWin/AppState.cs b/MicroWin/AppState.cs index f8dbd22..bab98c5 100755 --- a/MicroWin/AppState.cs +++ b/MicroWin/AppState.cs @@ -1,39 +1,27 @@ -using System.Collections.Generic; +using MicroWin.Classes; +using System.Collections.Generic; using System.IO; namespace MicroWin { - public class UserAccount - { - public string Name { get; set; } - public string Password { get; set; } - public string Role { get; set; } - } public static class AppState { - // 1. Path Definitions public static string IsoPath { get; set; } public static string TempRoot => Path.Combine(Path.GetTempPath(), "microwin"); - - // These provide the locations for the extraction and DISM workspace public static string MountPath => $"{Path.Combine(TempRoot, "mount")}"; public static string ScratchPath => $"{Path.Combine(TempRoot, "scratch")}"; - - // 2. Selection Data - public static int SelectedImageIndex { get; set; } - public static bool IsAuto { get; set; } - - // 3. Collections - public static List UserAccounts { get; set; } = new List(); - public static List SelectedPackages { get; set; } = new List(); - - // 4. Customization Toggles - public static bool AddWinUtilShortcut { get; set; } - public static bool AddReportingToolShortcut { get; set; } - - public static string saveISO { get; set; } - - public static string Version => "V1.0"; + public static int SelectedImageIndex { get; set; } = 0; + public static List UserAccounts { get; set; } = []; + /// + /// Determines whether to encode passwords with Base64 + /// + public static bool EncodeWithB64 { get; set; } = true; + public static bool AddReportingToolShortcut { get; set; } = true; + public static bool CopyUnattendToFileSystem { get; set; } + public static DriverExportMode DriverExportMode { get; set; } = DriverExportMode.NoExport; + public static string SaveISO { get; set; } + + public static string Version => "v1.99.2"; } } \ No newline at end of file diff --git a/MicroWin/Classes/DriverExportMode.cs b/MicroWin/Classes/DriverExportMode.cs new file mode 100644 index 0000000..e15ad27 --- /dev/null +++ b/MicroWin/Classes/DriverExportMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MicroWin.Classes +{ + public enum DriverExportMode : int + { + NoExport = 0, + ExportEssential = 1, + ExportAll = 2 + } +} diff --git a/MicroWin/Classes/UserAccount.cs b/MicroWin/Classes/UserAccount.cs new file mode 100644 index 0000000..6283ec6 --- /dev/null +++ b/MicroWin/Classes/UserAccount.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MicroWin.Classes +{ + public class UserAccount + { + public string Name { get; set; } + public string Password { get; set; } + public string Role { get; set; } + } +} diff --git a/MicroWin/MainForm.Designer.cs b/MicroWin/MainForm.Designer.cs index 093d23f..1f5bd67 100755 --- a/MicroWin/MainForm.Designer.cs +++ b/MicroWin/MainForm.Designer.cs @@ -28,12 +28,1124 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "MainForm"; + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.ButtonPanel = new System.Windows.Forms.Panel(); + this.TableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.Back_Button = new System.Windows.Forms.Button(); + this.Next_Button = new System.Windows.Forms.Button(); + this.Cancel_Button = new System.Windows.Forms.Button(); + this.PageContainerPanel = new System.Windows.Forms.Panel(); + this.ImageChooserPage = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.lvVersions = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.label3 = new System.Windows.Forms.Label(); + this.FinishPage = new System.Windows.Forms.Panel(); + this.lnkViewCreationLogs = new System.Windows.Forms.LinkLabel(); + this.lnkOpenIsoLoc = new System.Windows.Forms.LinkLabel(); + this.panel4 = new System.Windows.Forms.Panel(); + this.lnkUseNtLite = new System.Windows.Forms.LinkLabel(); + this.lnkUseDT = new System.Windows.Forms.LinkLabel(); + this.label18 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.IsoCreationPage = new System.Windows.Forms.Panel(); + this.pnlProgress = new System.Windows.Forms.Panel(); + this.pbOverall = new System.Windows.Forms.ProgressBar(); + this.pbCurrent = new System.Windows.Forms.ProgressBar(); + this.lblOverallStatus = new System.Windows.Forms.Label(); + this.lblCurrentStatus = new System.Windows.Forms.Label(); + this.logTB = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.IsoSettingsPage = new System.Windows.Forms.Panel(); + this.DriverExportCombo = new System.Windows.Forms.ComboBox(); + this.label13 = new System.Windows.Forms.Label(); + this.UnattendCopyCB = new System.Windows.Forms.CheckBox(); + this.ReportToolCB = new System.Windows.Forms.CheckBox(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.UserAccountsPage = new System.Windows.Forms.Panel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.panel3 = new System.Windows.Forms.Panel(); + this.label10 = new System.Windows.Forms.Label(); + this.lnkLusrMgr = new System.Windows.Forms.LinkLabel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.label9 = new System.Windows.Forms.Label(); + this.lnkImmersiveAccounts = new System.Windows.Forms.LinkLabel(); + this.label8 = new System.Windows.Forms.Label(); + this.b64CB = new System.Windows.Forms.CheckBox(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.usrNameTB = new System.Windows.Forms.TextBox(); + this.usrPasswordTB = new System.Windows.Forms.TextBox(); + this.usrNameCurrentSysNameBtn = new System.Windows.Forms.Button(); + this.usrPasswordRevealCB = new System.Windows.Forms.CheckBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.IsoChooserPage = new System.Windows.Forms.Panel(); + this.isoExtractionPB = new System.Windows.Forms.ProgressBar(); + this.isoPickerBtn = new System.Windows.Forms.Button(); + this.isoPathTB = new System.Windows.Forms.TextBox(); + this.lblExtractionStatus = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.SysCheckPage_Description = new System.Windows.Forms.Label(); + this.SysCheckPage_Header = new System.Windows.Forms.Label(); + this.WelcomePage = new System.Windows.Forms.Panel(); + this.lblDisclaimer = new System.Windows.Forms.Label(); + this.WelcomePage_Description = new System.Windows.Forms.Label(); + this.WelcomePage_Header = new System.Windows.Forms.Label(); + this.isoPickerOFD = new System.Windows.Forms.OpenFileDialog(); + this.isoSaverSFD = new System.Windows.Forms.SaveFileDialog(); + this.ButtonPanel.SuspendLayout(); + this.TableLayoutPanel1.SuspendLayout(); + this.PageContainerPanel.SuspendLayout(); + this.ImageChooserPage.SuspendLayout(); + this.FinishPage.SuspendLayout(); + this.panel4.SuspendLayout(); + this.IsoCreationPage.SuspendLayout(); + this.pnlProgress.SuspendLayout(); + this.IsoSettingsPage.SuspendLayout(); + this.UserAccountsPage.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + this.panel2.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + this.IsoChooserPage.SuspendLayout(); + this.WelcomePage.SuspendLayout(); + this.SuspendLayout(); + // + // ButtonPanel + // + this.ButtonPanel.Controls.Add(this.TableLayoutPanel1); + this.ButtonPanel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ButtonPanel.Location = new System.Drawing.Point(0, 521); + this.ButtonPanel.Name = "ButtonPanel"; + this.ButtonPanel.Size = new System.Drawing.Size(1008, 40); + this.ButtonPanel.TabIndex = 1; + // + // TableLayoutPanel1 + // + this.TableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.TableLayoutPanel1.ColumnCount = 3; + this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.TableLayoutPanel1.Controls.Add(this.Back_Button, 0, 0); + this.TableLayoutPanel1.Controls.Add(this.Next_Button, 1, 0); + this.TableLayoutPanel1.Controls.Add(this.Cancel_Button, 2, 0); + this.TableLayoutPanel1.Location = new System.Drawing.Point(777, 6); + this.TableLayoutPanel1.Name = "TableLayoutPanel1"; + this.TableLayoutPanel1.RowCount = 1; + this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.TableLayoutPanel1.Size = new System.Drawing.Size(219, 29); + this.TableLayoutPanel1.TabIndex = 1; + // + // Back_Button + // + this.Back_Button.Anchor = System.Windows.Forms.AnchorStyles.None; + this.Back_Button.Enabled = false; + this.Back_Button.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.Back_Button.Location = new System.Drawing.Point(4, 3); + this.Back_Button.Name = "Back_Button"; + this.Back_Button.Size = new System.Drawing.Size(64, 23); + this.Back_Button.TabIndex = 0; + this.Back_Button.Text = "Back"; + this.Back_Button.Click += new System.EventHandler(this.Back_Button_Click); + // + // Next_Button + // + this.Next_Button.Anchor = System.Windows.Forms.AnchorStyles.None; + this.Next_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Next_Button.Enabled = false; + this.Next_Button.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.Next_Button.Location = new System.Drawing.Point(77, 3); + this.Next_Button.Name = "Next_Button"; + this.Next_Button.Size = new System.Drawing.Size(64, 23); + this.Next_Button.TabIndex = 1; + this.Next_Button.Text = "Next"; + this.Next_Button.Click += new System.EventHandler(this.Next_Button_Click); + // + // Cancel_Button + // + this.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None; + this.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Cancel_Button.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.Cancel_Button.Location = new System.Drawing.Point(150, 3); + this.Cancel_Button.Name = "Cancel_Button"; + this.Cancel_Button.Size = new System.Drawing.Size(64, 23); + this.Cancel_Button.TabIndex = 1; + this.Cancel_Button.Text = "Cancel"; + // + // PageContainerPanel + // + this.PageContainerPanel.Controls.Add(this.FinishPage); + this.PageContainerPanel.Controls.Add(this.IsoCreationPage); + this.PageContainerPanel.Controls.Add(this.IsoSettingsPage); + this.PageContainerPanel.Controls.Add(this.UserAccountsPage); + this.PageContainerPanel.Controls.Add(this.ImageChooserPage); + this.PageContainerPanel.Controls.Add(this.IsoChooserPage); + this.PageContainerPanel.Controls.Add(this.WelcomePage); + this.PageContainerPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.PageContainerPanel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.PageContainerPanel.Location = new System.Drawing.Point(0, 0); + this.PageContainerPanel.Name = "PageContainerPanel"; + this.PageContainerPanel.Size = new System.Drawing.Size(1008, 521); + this.PageContainerPanel.TabIndex = 3; + // + // ImageChooserPage + // + this.ImageChooserPage.Controls.Add(this.label2); + this.ImageChooserPage.Controls.Add(this.lvVersions); + this.ImageChooserPage.Controls.Add(this.label3); + this.ImageChooserPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.ImageChooserPage.Location = new System.Drawing.Point(0, 0); + this.ImageChooserPage.Name = "ImageChooserPage"; + this.ImageChooserPage.Size = new System.Drawing.Size(1008, 521); + this.ImageChooserPage.TabIndex = 4; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(80, 448); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(529, 15); + this.label2.TabIndex = 4; + this.label2.Text = "We have automatically picked the Pro edition for you. However, you can still sele" + + "ct another edition."; + // + // lvVersions + // + this.lvVersions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lvVersions.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lvVersions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5}); + this.lvVersions.FullRowSelect = true; + this.lvVersions.HideSelection = false; + this.lvVersions.Location = new System.Drawing.Point(80, 89); + this.lvVersions.MultiSelect = false; + this.lvVersions.Name = "lvVersions"; + this.lvVersions.Size = new System.Drawing.Size(849, 352); + this.lvVersions.TabIndex = 3; + this.lvVersions.UseCompatibleStateImageBehavior = false; + this.lvVersions.View = System.Windows.Forms.View.Details; + this.lvVersions.SelectedIndexChanged += new System.EventHandler(this.lvVersions_SelectedIndexChanged); + // + // columnHeader1 + // + this.columnHeader1.Text = "#"; + this.columnHeader1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.columnHeader1.Width = 32; + // + // columnHeader2 + // + this.columnHeader2.Text = "Name"; + this.columnHeader2.Width = 200; + // + // columnHeader3 + // + this.columnHeader3.Text = "Description"; + this.columnHeader3.Width = 256; + // + // columnHeader4 + // + this.columnHeader4.Text = "Architecture"; + this.columnHeader4.Width = 84; + // + // columnHeader5 + // + this.columnHeader5.Text = "Last Modified"; + this.columnHeader5.Width = 160; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label3.AutoEllipsis = true; + this.label3.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(14, 12); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(980, 45); + this.label3.TabIndex = 2; + this.label3.Text = "Choose the image to modify"; + // + // FinishPage + // + this.FinishPage.Controls.Add(this.lnkViewCreationLogs); + this.FinishPage.Controls.Add(this.lnkOpenIsoLoc); + this.FinishPage.Controls.Add(this.panel4); + this.FinishPage.Controls.Add(this.label16); + this.FinishPage.Controls.Add(this.label17); + this.FinishPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.FinishPage.Location = new System.Drawing.Point(0, 0); + this.FinishPage.Name = "FinishPage"; + this.FinishPage.Size = new System.Drawing.Size(1008, 521); + this.FinishPage.TabIndex = 8; + // + // lnkViewCreationLogs + // + this.lnkViewCreationLogs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lnkViewCreationLogs.AutoSize = true; + this.lnkViewCreationLogs.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkViewCreationLogs.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkViewCreationLogs.Location = new System.Drawing.Point(99, 441); + this.lnkViewCreationLogs.Name = "lnkViewCreationLogs"; + this.lnkViewCreationLogs.Size = new System.Drawing.Size(124, 15); + this.lnkViewCreationLogs.TabIndex = 12; + this.lnkViewCreationLogs.TabStop = true; + this.lnkViewCreationLogs.Text = "View ISO creation logs"; + // + // lnkOpenIsoLoc + // + this.lnkOpenIsoLoc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lnkOpenIsoLoc.AutoSize = true; + this.lnkOpenIsoLoc.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkOpenIsoLoc.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkOpenIsoLoc.Location = new System.Drawing.Point(99, 416); + this.lnkOpenIsoLoc.Name = "lnkOpenIsoLoc"; + this.lnkOpenIsoLoc.Size = new System.Drawing.Size(103, 15); + this.lnkOpenIsoLoc.TabIndex = 12; + this.lnkOpenIsoLoc.TabStop = true; + this.lnkOpenIsoLoc.Text = "Open ISO location"; + this.lnkOpenIsoLoc.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkOpenIsoLoc_LinkClicked); + // + // panel4 + // + this.panel4.Anchor = System.Windows.Forms.AnchorStyles.None; + this.panel4.Controls.Add(this.lnkUseNtLite); + this.panel4.Controls.Add(this.lnkUseDT); + this.panel4.Controls.Add(this.label18); + this.panel4.Location = new System.Drawing.Point(101, 123); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(806, 276); + this.panel4.TabIndex = 11; + // + // lnkUseNtLite + // + this.lnkUseNtLite.AutoSize = true; + this.lnkUseNtLite.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lnkUseNtLite.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkUseNtLite.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkUseNtLite.Location = new System.Drawing.Point(101, 193); + this.lnkUseNtLite.Name = "lnkUseNtLite"; + this.lnkUseNtLite.Size = new System.Drawing.Size(55, 21); + this.lnkUseNtLite.TabIndex = 11; + this.lnkUseNtLite.TabStop = true; + this.lnkUseNtLite.Text = "NTLite"; + this.lnkUseNtLite.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkUseNtLite_LinkClicked); + // + // lnkUseDT + // + this.lnkUseDT.AutoSize = true; + this.lnkUseDT.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lnkUseDT.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkUseDT.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkUseDT.Location = new System.Drawing.Point(101, 160); + this.lnkUseDT.Name = "lnkUseDT"; + this.lnkUseDT.Size = new System.Drawing.Size(83, 21); + this.lnkUseDT.TabIndex = 11; + this.lnkUseDT.TabStop = true; + this.lnkUseDT.Text = "DISMTools"; + this.lnkUseDT.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkUseDT_LinkClicked); + // + // label18 + // + this.label18.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label18.AutoEllipsis = true; + this.label18.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label18.Location = new System.Drawing.Point(51, 31); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(704, 95); + this.label18.TabIndex = 10; + this.label18.Text = resources.GetString("label18.Text"); + this.label18.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // label16 + // + this.label16.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label16.AutoEllipsis = true; + this.label16.Location = new System.Drawing.Point(17, 64); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(977, 52); + this.label16.TabIndex = 10; + this.label16.Text = "Your ISO file is now ready for operating system installation."; + // + // label17 + // + this.label17.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label17.AutoEllipsis = true; + this.label17.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label17.Location = new System.Drawing.Point(14, 12); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(980, 45); + this.label17.TabIndex = 9; + this.label17.Text = "Customizations complete"; + // + // IsoCreationPage + // + this.IsoCreationPage.Controls.Add(this.pnlProgress); + this.IsoCreationPage.Controls.Add(this.logTB); + this.IsoCreationPage.Controls.Add(this.label14); + this.IsoCreationPage.Controls.Add(this.label15); + this.IsoCreationPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.IsoCreationPage.Location = new System.Drawing.Point(0, 0); + this.IsoCreationPage.Name = "IsoCreationPage"; + this.IsoCreationPage.Size = new System.Drawing.Size(1008, 521); + this.IsoCreationPage.TabIndex = 7; + // + // pnlProgress + // + this.pnlProgress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlProgress.Controls.Add(this.pbOverall); + this.pnlProgress.Controls.Add(this.pbCurrent); + this.pnlProgress.Controls.Add(this.lblOverallStatus); + this.pnlProgress.Controls.Add(this.lblCurrentStatus); + this.pnlProgress.Location = new System.Drawing.Point(19, 405); + this.pnlProgress.Name = "pnlProgress"; + this.pnlProgress.Size = new System.Drawing.Size(971, 110); + this.pnlProgress.TabIndex = 10; + // + // pbOverall + // + this.pbOverall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pbOverall.Location = new System.Drawing.Point(14, 77); + this.pbOverall.Name = "pbOverall"; + this.pbOverall.Size = new System.Drawing.Size(941, 23); + this.pbOverall.TabIndex = 1; + // + // pbCurrent + // + this.pbCurrent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pbCurrent.Location = new System.Drawing.Point(14, 30); + this.pbCurrent.Name = "pbCurrent"; + this.pbCurrent.Size = new System.Drawing.Size(941, 23); + this.pbCurrent.TabIndex = 1; + // + // lblOverallStatus + // + this.lblOverallStatus.AutoSize = true; + this.lblOverallStatus.Location = new System.Drawing.Point(11, 58); + this.lblOverallStatus.Name = "lblOverallStatus"; + this.lblOverallStatus.Size = new System.Drawing.Size(95, 15); + this.lblOverallStatus.TabIndex = 0; + this.lblOverallStatus.Text = "Overall Progress:"; + // + // lblCurrentStatus + // + this.lblCurrentStatus.AutoSize = true; + this.lblCurrentStatus.Location = new System.Drawing.Point(11, 11); + this.lblCurrentStatus.Name = "lblCurrentStatus"; + this.lblCurrentStatus.Size = new System.Drawing.Size(98, 15); + this.lblCurrentStatus.TabIndex = 0; + this.lblCurrentStatus.Text = "Current Progress:"; + // + // logTB + // + this.logTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.logTB.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.logTB.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.logTB.Location = new System.Drawing.Point(99, 128); + this.logTB.Multiline = true; + this.logTB.Name = "logTB"; + this.logTB.ReadOnly = true; + this.logTB.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.logTB.Size = new System.Drawing.Size(790, 248); + this.logTB.TabIndex = 9; + // + // label14 + // + this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label14.AutoEllipsis = true; + this.label14.Location = new System.Drawing.Point(17, 64); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(977, 52); + this.label14.TabIndex = 8; + this.label14.Text = "This process will take several minutes; please be patient."; + // + // label15 + // + this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label15.AutoEllipsis = true; + this.label15.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label15.Location = new System.Drawing.Point(14, 12); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(980, 45); + this.label15.TabIndex = 7; + this.label15.Text = "Customizations in progress"; + // + // IsoSettingsPage + // + this.IsoSettingsPage.Controls.Add(this.DriverExportCombo); + this.IsoSettingsPage.Controls.Add(this.label13); + this.IsoSettingsPage.Controls.Add(this.UnattendCopyCB); + this.IsoSettingsPage.Controls.Add(this.ReportToolCB); + this.IsoSettingsPage.Controls.Add(this.label11); + this.IsoSettingsPage.Controls.Add(this.label12); + this.IsoSettingsPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.IsoSettingsPage.Location = new System.Drawing.Point(0, 0); + this.IsoSettingsPage.Name = "IsoSettingsPage"; + this.IsoSettingsPage.Size = new System.Drawing.Size(1008, 521); + this.IsoSettingsPage.TabIndex = 6; + // + // DriverExportCombo + // + this.DriverExportCombo.FormattingEnabled = true; + this.DriverExportCombo.Items.AddRange(new object[] { + "Don\'t export drivers", + "Export essential drivers (SCSI Adapters/Storage Controllers)", + "Export all drivers"}); + this.DriverExportCombo.Location = new System.Drawing.Point(83, 206); + this.DriverExportCombo.Name = "DriverExportCombo"; + this.DriverExportCombo.Size = new System.Drawing.Size(374, 23); + this.DriverExportCombo.TabIndex = 9; + this.DriverExportCombo.SelectedIndexChanged += new System.EventHandler(this.DriverExportCombo_SelectedIndexChanged); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(80, 185); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(111, 15); + this.label13.TabIndex = 8; + this.label13.Text = "Driver export mode:"; + // + // UnattendCopyCB + // + this.UnattendCopyCB.AutoSize = true; + this.UnattendCopyCB.Location = new System.Drawing.Point(83, 158); + this.UnattendCopyCB.Name = "UnattendCopyCB"; + this.UnattendCopyCB.Size = new System.Drawing.Size(412, 19); + this.UnattendCopyCB.TabIndex = 7; + this.UnattendCopyCB.Text = "Make a copy of the unattended answer file that I can use on other images"; + this.UnattendCopyCB.UseVisualStyleBackColor = true; + this.UnattendCopyCB.CheckedChanged += new System.EventHandler(this.UnattendCopyCB_CheckedChanged); + // + // ReportToolCB + // + this.ReportToolCB.AutoSize = true; + this.ReportToolCB.Checked = true; + this.ReportToolCB.CheckState = System.Windows.Forms.CheckState.Checked; + this.ReportToolCB.Location = new System.Drawing.Point(83, 133); + this.ReportToolCB.Name = "ReportToolCB"; + this.ReportToolCB.Size = new System.Drawing.Size(218, 19); + this.ReportToolCB.TabIndex = 7; + this.ReportToolCB.Text = "Add a shortcut for the reporting tool"; + this.ReportToolCB.UseVisualStyleBackColor = true; + this.ReportToolCB.CheckedChanged += new System.EventHandler(this.ReportToolCB_CheckedChanged); + // + // label11 + // + this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label11.AutoEllipsis = true; + this.label11.Location = new System.Drawing.Point(17, 64); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(977, 52); + this.label11.TabIndex = 6; + this.label11.Text = "Configure additional settings for your customized image."; + // + // label12 + // + this.label12.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label12.AutoEllipsis = true; + this.label12.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Location = new System.Drawing.Point(14, 12); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(980, 45); + this.label12.TabIndex = 5; + this.label12.Text = "Specify additional settings for the image"; + // + // UserAccountsPage + // + this.UserAccountsPage.Controls.Add(this.panel1); + this.UserAccountsPage.Controls.Add(this.b64CB); + this.UserAccountsPage.Controls.Add(this.tableLayoutPanel2); + this.UserAccountsPage.Controls.Add(this.label5); + this.UserAccountsPage.Controls.Add(this.label4); + this.UserAccountsPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.UserAccountsPage.Location = new System.Drawing.Point(0, 0); + this.UserAccountsPage.Name = "UserAccountsPage"; + this.UserAccountsPage.Size = new System.Drawing.Size(1008, 521); + this.UserAccountsPage.TabIndex = 5; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.tableLayoutPanel3); + this.panel1.Controls.Add(this.label8); + this.panel1.Location = new System.Drawing.Point(85, 254); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(838, 236); + this.panel1.TabIndex = 7; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.ColumnCount = 2; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 47.61337F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 52.38663F)); + this.tableLayoutPanel3.Controls.Add(this.panel3, 0, 1); + this.tableLayoutPanel3.Controls.Add(this.pictureBox1, 1, 0); + this.tableLayoutPanel3.Controls.Add(this.pictureBox2, 1, 1); + this.tableLayoutPanel3.Controls.Add(this.panel2, 0, 0); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 29); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 2; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 41.54589F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 58.45411F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(838, 207); + this.tableLayoutPanel3.TabIndex = 2; + // + // panel3 + // + this.panel3.Controls.Add(this.label10); + this.panel3.Controls.Add(this.lnkLusrMgr); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(3, 88); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(393, 116); + this.panel3.TabIndex = 3; + // + // label10 + // + this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label10.AutoEllipsis = true; + this.label10.Location = new System.Drawing.Point(8, 8); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(375, 62); + this.label10.TabIndex = 4; + this.label10.Text = "- Open Local Users and Groups, then go to Users"; + // + // lnkLusrMgr + // + this.lnkLusrMgr.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lnkLusrMgr.AutoSize = true; + this.lnkLusrMgr.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkLusrMgr.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkLusrMgr.Location = new System.Drawing.Point(302, 91); + this.lnkLusrMgr.Name = "lnkLusrMgr"; + this.lnkLusrMgr.Size = new System.Drawing.Size(81, 15); + this.lnkLusrMgr.TabIndex = 0; + this.lnkLusrMgr.TabStop = true; + this.lnkLusrMgr.Text = "Take me there"; + this.lnkLusrMgr.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkLusrMgr_LinkClicked); + // + // pictureBox1 + // + this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox1.Image = global::MicroWin.Properties.Resources.user_creation_settings; + this.pictureBox1.Location = new System.Drawing.Point(402, 3); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(433, 79); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 1; + this.pictureBox1.TabStop = false; + // + // pictureBox2 + // + this.pictureBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox2.Image = global::MicroWin.Properties.Resources.user_creation_lusrmgr; + this.pictureBox2.Location = new System.Drawing.Point(402, 88); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(433, 116); + this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox2.TabIndex = 1; + this.pictureBox2.TabStop = false; + // + // panel2 + // + this.panel2.Controls.Add(this.label9); + this.panel2.Controls.Add(this.lnkImmersiveAccounts); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(3, 3); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(393, 79); + this.panel2.TabIndex = 2; + // + // label9 + // + this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label9.AutoEllipsis = true; + this.label9.Location = new System.Drawing.Point(8, 8); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(293, 43); + this.label9.TabIndex = 4; + this.label9.Text = "- Head over to Settings > Accounts > Other Users"; + // + // lnkImmersiveAccounts + // + this.lnkImmersiveAccounts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lnkImmersiveAccounts.AutoSize = true; + this.lnkImmersiveAccounts.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; + this.lnkImmersiveAccounts.LinkColor = System.Drawing.Color.DodgerBlue; + this.lnkImmersiveAccounts.Location = new System.Drawing.Point(302, 54); + this.lnkImmersiveAccounts.Name = "lnkImmersiveAccounts"; + this.lnkImmersiveAccounts.Size = new System.Drawing.Size(81, 15); + this.lnkImmersiveAccounts.TabIndex = 0; + this.lnkImmersiveAccounts.TabStop = true; + this.lnkImmersiveAccounts.Text = "Take me there"; + this.lnkImmersiveAccounts.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkImmersiveAccounts_LinkClicked); + // + // label8 + // + this.label8.Dock = System.Windows.Forms.DockStyle.Top; + this.label8.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.Location = new System.Drawing.Point(0, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(838, 29); + this.label8.TabIndex = 0; + this.label8.Text = "To set up new accounts:"; + // + // b64CB + // + this.b64CB.AutoSize = true; + this.b64CB.Checked = true; + this.b64CB.CheckState = System.Windows.Forms.CheckState.Checked; + this.b64CB.Location = new System.Drawing.Point(85, 200); + this.b64CB.Name = "b64CB"; + this.b64CB.Size = new System.Drawing.Size(259, 19); + this.b64CB.TabIndex = 6; + this.b64CB.Text = "Encode password in Base64 (recommended)"; + this.b64CB.UseVisualStyleBackColor = true; + this.b64CB.CheckedChanged += new System.EventHandler(this.b64CB_CheckedChanged); + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel2.ColumnCount = 3; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 19.12799F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60.85919F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.04773F)); + this.tableLayoutPanel2.Controls.Add(this.label6, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.label7, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.usrNameTB, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.usrPasswordTB, 1, 1); + this.tableLayoutPanel2.Controls.Add(this.usrNameCurrentSysNameBtn, 2, 0); + this.tableLayoutPanel2.Controls.Add(this.usrPasswordRevealCB, 2, 1); + this.tableLayoutPanel2.Location = new System.Drawing.Point(85, 133); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 2; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(838, 59); + this.tableLayoutPanel2.TabIndex = 5; + // + // label6 + // + this.label6.AutoEllipsis = true; + this.label6.Dock = System.Windows.Forms.DockStyle.Fill; + this.label6.Location = new System.Drawing.Point(3, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(154, 29); + this.label6.TabIndex = 4; + this.label6.Text = "User Name:"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label7 + // + this.label7.AutoEllipsis = true; + this.label7.Dock = System.Windows.Forms.DockStyle.Fill; + this.label7.Location = new System.Drawing.Point(3, 29); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(154, 30); + this.label7.TabIndex = 4; + this.label7.Text = "Password:"; + this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // usrNameTB + // + this.usrNameTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.usrNameTB.Dock = System.Windows.Forms.DockStyle.Fill; + this.usrNameTB.Location = new System.Drawing.Point(163, 3); + this.usrNameTB.MaxLength = 20; + this.usrNameTB.Name = "usrNameTB"; + this.usrNameTB.Size = new System.Drawing.Size(503, 23); + this.usrNameTB.TabIndex = 5; + this.usrNameTB.TextChanged += new System.EventHandler(this.usrNameTB_TextChanged); + // + // usrPasswordTB + // + this.usrPasswordTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.usrPasswordTB.Dock = System.Windows.Forms.DockStyle.Fill; + this.usrPasswordTB.Location = new System.Drawing.Point(163, 32); + this.usrPasswordTB.Name = "usrPasswordTB"; + this.usrPasswordTB.PasswordChar = '*'; + this.usrPasswordTB.Size = new System.Drawing.Size(503, 23); + this.usrPasswordTB.TabIndex = 5; + this.usrPasswordTB.TextChanged += new System.EventHandler(this.usrPasswordTB_TextChanged); + // + // usrNameCurrentSysNameBtn + // + this.usrNameCurrentSysNameBtn.Dock = System.Windows.Forms.DockStyle.Fill; + this.usrNameCurrentSysNameBtn.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.usrNameCurrentSysNameBtn.Location = new System.Drawing.Point(672, 3); + this.usrNameCurrentSysNameBtn.Name = "usrNameCurrentSysNameBtn"; + this.usrNameCurrentSysNameBtn.Size = new System.Drawing.Size(163, 23); + this.usrNameCurrentSysNameBtn.TabIndex = 6; + this.usrNameCurrentSysNameBtn.Text = "Use current user name"; + this.usrNameCurrentSysNameBtn.UseVisualStyleBackColor = true; + this.usrNameCurrentSysNameBtn.Click += new System.EventHandler(this.usrNameCurrentSysNameBtn_Click); + // + // usrPasswordRevealCB + // + this.usrPasswordRevealCB.Appearance = System.Windows.Forms.Appearance.Button; + this.usrPasswordRevealCB.AutoSize = true; + this.usrPasswordRevealCB.Dock = System.Windows.Forms.DockStyle.Fill; + this.usrPasswordRevealCB.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.usrPasswordRevealCB.Location = new System.Drawing.Point(672, 32); + this.usrPasswordRevealCB.Name = "usrPasswordRevealCB"; + this.usrPasswordRevealCB.Size = new System.Drawing.Size(163, 24); + this.usrPasswordRevealCB.TabIndex = 7; + this.usrPasswordRevealCB.Text = "Reveal password"; + this.usrPasswordRevealCB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.usrPasswordRevealCB.UseVisualStyleBackColor = true; + this.usrPasswordRevealCB.CheckedChanged += new System.EventHandler(this.usrPasswordRevealCB_CheckedChanged); + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label5.AutoEllipsis = true; + this.label5.Location = new System.Drawing.Point(17, 64); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(977, 52); + this.label5.TabIndex = 4; + this.label5.Text = resources.GetString("label5.Text"); + // + // label4 + // + this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label4.AutoEllipsis = true; + this.label4.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(14, 12); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(980, 45); + this.label4.TabIndex = 3; + this.label4.Text = "Who will use the computer?"; + // + // IsoChooserPage + // + this.IsoChooserPage.Controls.Add(this.isoExtractionPB); + this.IsoChooserPage.Controls.Add(this.isoPickerBtn); + this.IsoChooserPage.Controls.Add(this.isoPathTB); + this.IsoChooserPage.Controls.Add(this.lblExtractionStatus); + this.IsoChooserPage.Controls.Add(this.label1); + this.IsoChooserPage.Controls.Add(this.SysCheckPage_Description); + this.IsoChooserPage.Controls.Add(this.SysCheckPage_Header); + this.IsoChooserPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.IsoChooserPage.Location = new System.Drawing.Point(0, 0); + this.IsoChooserPage.Name = "IsoChooserPage"; + this.IsoChooserPage.Size = new System.Drawing.Size(1008, 521); + this.IsoChooserPage.TabIndex = 1; + this.IsoChooserPage.Visible = false; + // + // isoExtractionPB + // + this.isoExtractionPB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.isoExtractionPB.Location = new System.Drawing.Point(125, 219); + this.isoExtractionPB.Name = "isoExtractionPB"; + this.isoExtractionPB.Size = new System.Drawing.Size(719, 23); + this.isoExtractionPB.TabIndex = 4; + // + // isoPickerBtn + // + this.isoPickerBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.isoPickerBtn.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.isoPickerBtn.Location = new System.Drawing.Point(769, 146); + this.isoPickerBtn.Name = "isoPickerBtn"; + this.isoPickerBtn.Size = new System.Drawing.Size(75, 23); + this.isoPickerBtn.TabIndex = 3; + this.isoPickerBtn.Text = "Browse..."; + this.isoPickerBtn.UseVisualStyleBackColor = true; + this.isoPickerBtn.Click += new System.EventHandler(this.isoPickerBtn_Click); + // + // isoPathTB + // + this.isoPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.isoPathTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.isoPathTB.Location = new System.Drawing.Point(125, 147); + this.isoPathTB.Name = "isoPathTB"; + this.isoPathTB.ReadOnly = true; + this.isoPathTB.Size = new System.Drawing.Size(638, 23); + this.isoPathTB.TabIndex = 2; + this.isoPathTB.TextChanged += new System.EventHandler(this.isoPathTB_TextChanged); + // + // lblExtractionStatus + // + this.lblExtractionStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblExtractionStatus.AutoEllipsis = true; + this.lblExtractionStatus.AutoSize = true; + this.lblExtractionStatus.Location = new System.Drawing.Point(122, 200); + this.lblExtractionStatus.Name = "lblExtractionStatus"; + this.lblExtractionStatus.Size = new System.Drawing.Size(243, 15); + this.lblExtractionStatus.TabIndex = 1; + this.lblExtractionStatus.Text = "Disc image extraction status will appear here."; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoEllipsis = true; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(122, 128); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 15); + this.label1.TabIndex = 1; + this.label1.Text = "Disc image:"; + // + // SysCheckPage_Description + // + this.SysCheckPage_Description.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SysCheckPage_Description.AutoEllipsis = true; + this.SysCheckPage_Description.Location = new System.Drawing.Point(17, 64); + this.SysCheckPage_Description.Name = "SysCheckPage_Description"; + this.SysCheckPage_Description.Size = new System.Drawing.Size(977, 52); + this.SysCheckPage_Description.TabIndex = 1; + this.SysCheckPage_Description.Text = "Please specify the ISO that you want to use with this wizard. Supported operating" + + " systems are Windows 10 and Windows 11."; + // + // SysCheckPage_Header + // + this.SysCheckPage_Header.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SysCheckPage_Header.AutoEllipsis = true; + this.SysCheckPage_Header.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SysCheckPage_Header.Location = new System.Drawing.Point(14, 12); + this.SysCheckPage_Header.Name = "SysCheckPage_Header"; + this.SysCheckPage_Header.Size = new System.Drawing.Size(980, 45); + this.SysCheckPage_Header.TabIndex = 0; + this.SysCheckPage_Header.Text = "Choose a disc image"; + // + // WelcomePage + // + this.WelcomePage.Controls.Add(this.lblDisclaimer); + this.WelcomePage.Controls.Add(this.WelcomePage_Description); + this.WelcomePage.Controls.Add(this.WelcomePage_Header); + this.WelcomePage.Dock = System.Windows.Forms.DockStyle.Fill; + this.WelcomePage.Location = new System.Drawing.Point(0, 0); + this.WelcomePage.Name = "WelcomePage"; + this.WelcomePage.Size = new System.Drawing.Size(1008, 521); + this.WelcomePage.TabIndex = 0; + // + // lblDisclaimer + // + this.lblDisclaimer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblDisclaimer.AutoEllipsis = true; + this.lblDisclaimer.Location = new System.Drawing.Point(119, 128); + this.lblDisclaimer.Name = "lblDisclaimer"; + this.lblDisclaimer.Size = new System.Drawing.Size(770, 313); + this.lblDisclaimer.TabIndex = 1; + // + // WelcomePage_Description + // + this.WelcomePage_Description.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.WelcomePage_Description.AutoEllipsis = true; + this.WelcomePage_Description.Location = new System.Drawing.Point(17, 64); + this.WelcomePage_Description.Name = "WelcomePage_Description"; + this.WelcomePage_Description.Size = new System.Drawing.Size(977, 52); + this.WelcomePage_Description.TabIndex = 1; + this.WelcomePage_Description.Text = "This wizard will help you configure your Windows image. To begin, click Next."; + // + // WelcomePage_Header + // + this.WelcomePage_Header.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.WelcomePage_Header.AutoEllipsis = true; + this.WelcomePage_Header.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.WelcomePage_Header.Location = new System.Drawing.Point(14, 12); + this.WelcomePage_Header.Name = "WelcomePage_Header"; + this.WelcomePage_Header.Size = new System.Drawing.Size(980, 45); + this.WelcomePage_Header.TabIndex = 0; + this.WelcomePage_Header.Text = "Welcome"; + // + // isoPickerOFD + // + this.isoPickerOFD.Filter = "ISO Files|*.iso"; + this.isoPickerOFD.FileOk += new System.ComponentModel.CancelEventHandler(this.isoPickerOFD_FileOk); + // + // isoSaverSFD + // + this.isoSaverSFD.Filter = "ISO Files|*.iso"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(1008, 561); + this.Controls.Add(this.PageContainerPanel); + this.Controls.Add(this.ButtonPanel); + this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MinimumSize = new System.Drawing.Size(1024, 600); + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "MicroWin .NET"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); + this.Load += new System.EventHandler(this.MainForm_Load); + this.SizeChanged += new System.EventHandler(this.MainForm_SizeChanged); + this.ButtonPanel.ResumeLayout(false); + this.TableLayoutPanel1.ResumeLayout(false); + this.PageContainerPanel.ResumeLayout(false); + this.ImageChooserPage.ResumeLayout(false); + this.ImageChooserPage.PerformLayout(); + this.FinishPage.ResumeLayout(false); + this.FinishPage.PerformLayout(); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); + this.IsoCreationPage.ResumeLayout(false); + this.IsoCreationPage.PerformLayout(); + this.pnlProgress.ResumeLayout(false); + this.pnlProgress.PerformLayout(); + this.IsoSettingsPage.ResumeLayout(false); + this.IsoSettingsPage.PerformLayout(); + this.UserAccountsPage.ResumeLayout(false); + this.UserAccountsPage.PerformLayout(); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel3.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + this.IsoChooserPage.ResumeLayout(false); + this.IsoChooserPage.PerformLayout(); + this.WelcomePage.ResumeLayout(false); + this.ResumeLayout(false); + } #endregion + + internal System.Windows.Forms.Panel ButtonPanel; + internal System.Windows.Forms.TableLayoutPanel TableLayoutPanel1; + internal System.Windows.Forms.Button Back_Button; + internal System.Windows.Forms.Button Next_Button; + internal System.Windows.Forms.Button Cancel_Button; + internal System.Windows.Forms.Panel PageContainerPanel; + internal System.Windows.Forms.Panel WelcomePage; + internal System.Windows.Forms.Label WelcomePage_Description; + internal System.Windows.Forms.Label WelcomePage_Header; + internal System.Windows.Forms.Panel IsoChooserPage; + internal System.Windows.Forms.Label SysCheckPage_Description; + internal System.Windows.Forms.Label SysCheckPage_Header; + internal System.Windows.Forms.Label lblDisclaimer; + internal System.Windows.Forms.Label label1; + private System.Windows.Forms.Button isoPickerBtn; + private System.Windows.Forms.TextBox isoPathTB; + private System.Windows.Forms.ProgressBar isoExtractionPB; + internal System.Windows.Forms.Label lblExtractionStatus; + private System.Windows.Forms.OpenFileDialog isoPickerOFD; + private System.Windows.Forms.Panel ImageChooserPage; + private System.Windows.Forms.ListView lvVersions; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + internal System.Windows.Forms.Label label3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel UserAccountsPage; + internal System.Windows.Forms.Label label4; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + internal System.Windows.Forms.Label label6; + internal System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox usrNameTB; + private System.Windows.Forms.TextBox usrPasswordTB; + internal System.Windows.Forms.Label label5; + private System.Windows.Forms.CheckBox b64CB; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Panel panel2; + internal System.Windows.Forms.Label label9; + private System.Windows.Forms.LinkLabel lnkImmersiveAccounts; + private System.Windows.Forms.Panel panel3; + internal System.Windows.Forms.Label label10; + private System.Windows.Forms.LinkLabel lnkLusrMgr; + private System.Windows.Forms.Button usrNameCurrentSysNameBtn; + private System.Windows.Forms.CheckBox usrPasswordRevealCB; + private System.Windows.Forms.Panel IsoSettingsPage; + internal System.Windows.Forms.Label label11; + internal System.Windows.Forms.Label label12; + private System.Windows.Forms.CheckBox ReportToolCB; + private System.Windows.Forms.ComboBox DriverExportCombo; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.CheckBox UnattendCopyCB; + private System.Windows.Forms.Panel IsoCreationPage; + internal System.Windows.Forms.Label label14; + internal System.Windows.Forms.Label label15; + private System.Windows.Forms.Panel pnlProgress; + private System.Windows.Forms.ProgressBar pbOverall; + private System.Windows.Forms.ProgressBar pbCurrent; + private System.Windows.Forms.Label lblOverallStatus; + private System.Windows.Forms.Label lblCurrentStatus; + private System.Windows.Forms.TextBox logTB; + private System.Windows.Forms.SaveFileDialog isoSaverSFD; + private System.Windows.Forms.Panel FinishPage; + internal System.Windows.Forms.Label label16; + internal System.Windows.Forms.Label label17; + internal System.Windows.Forms.Label label18; + private System.Windows.Forms.LinkLabel lnkViewCreationLogs; + private System.Windows.Forms.LinkLabel lnkOpenIsoLoc; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.LinkLabel lnkUseNtLite; + private System.Windows.Forms.LinkLabel lnkUseDT; } } \ No newline at end of file diff --git a/MicroWin/MainForm.cs b/MicroWin/MainForm.cs index 516de7e..bbb332e 100755 --- a/MicroWin/MainForm.cs +++ b/MicroWin/MainForm.cs @@ -1,43 +1,623 @@ -using System; +using Microsoft.Dism; +using Microsoft.Win32; +using MicroWin.Classes; +using MicroWin.functions.dism; +using MicroWin.functions.Helpers.DeleteFile; +using MicroWin.functions.Helpers.DesktopWindowManager; +using MicroWin.functions.Helpers.Loggers; +using MicroWin.functions.Helpers.PropertyCheckers; +using MicroWin.functions.Helpers.RegistryHelpers; +using MicroWin.functions.iso; +using MicroWin.functions.UI; +using MicroWin.OSCDIMG; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; using System.Windows.Forms; namespace MicroWin { public partial class MainForm : Form { - private Panel pnlContent; + private const string swStatus = "BETA"; + + private WizardPage CurrentWizardPage = new(); + private List VerifyInPages = [ + WizardPage.Page.IsoChooserPage, + WizardPage.Page.ImageChooserPage, + WizardPage.Page.UserAccountsPage + ]; + + private bool BusyCannotClose = false; + private DismImageInfoCollection imageInfo; + + private DismImageInfo installImageInfo; public MainForm() { - this.Text = "MicroWin .NET (ALPHA 0.1)"; - this.Size = new Size(600, 450); - this.StartPosition = FormStartPosition.CenterScreen; + InitializeComponent(); + } + + private void SetColorMode() + { + RegistryKey colorRk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); + int colorVal = (int)colorRk.GetValue("AppsUseLightTheme", 1); + colorRk.Close(); + if (colorVal == 0) + { + BackColor = Color.FromArgb(35, 38, 41); + ForeColor = Color.FromArgb(247, 247, 247); + } + else + { + BackColor = Color.FromArgb(247, 247, 247); + ForeColor = Color.FromArgb(35, 38, 41); + } + + // Change colors of other components. I want consistency + isoPathTB.BackColor = BackColor; + isoPathTB.ForeColor = ForeColor; + lvVersions.BackColor = BackColor; + lvVersions.ForeColor = ForeColor; + usrNameTB.BackColor = BackColor; + usrNameTB.ForeColor = ForeColor; + usrPasswordTB.BackColor = BackColor; + usrPasswordTB.ForeColor = ForeColor; + DriverExportCombo.BackColor = BackColor; + DriverExportCombo.ForeColor = ForeColor; + logTB.BackColor = BackColor; + logTB.ForeColor = ForeColor; + + WindowHelper.ToggleDarkTitleBar(Handle, colorVal == 0); + } + + private void ChangePage(WizardPage.Page newPage) + { + DynaLog.logMessage("Changing current page of the wizard..."); + DynaLog.logMessage($"New page to load: {newPage.ToString()}"); + + if (newPage > CurrentWizardPage.wizardPage && VerifyInPages.Contains(CurrentWizardPage.wizardPage)) + { + if (!VerifyOptionsInPage(CurrentWizardPage.wizardPage)) + return; + } + + WelcomePage.Visible = newPage == WizardPage.Page.WelcomePage; + IsoChooserPage.Visible = newPage == WizardPage.Page.IsoChooserPage; + ImageChooserPage.Visible = newPage == WizardPage.Page.ImageChooserPage; + UserAccountsPage.Visible = newPage == WizardPage.Page.UserAccountsPage; + IsoSettingsPage.Visible = newPage == WizardPage.Page.IsoSettingsPage; + IsoCreationPage.Visible = newPage == WizardPage.Page.IsoCreationPage; + FinishPage.Visible = newPage == WizardPage.Page.FinishPage; + + CurrentWizardPage.wizardPage = newPage; + + // Handle tasks when switching to certain pages + switch (newPage) + { + case WizardPage.Page.ImageChooserPage: + LoadWimData(); + break; + } + + Next_Button.Enabled = !(newPage != WizardPage.Page.FinishPage) || !((int)newPage + 1 >= WizardPage.PageCount); + Cancel_Button.Enabled = !(newPage == WizardPage.Page.FinishPage); + Back_Button.Enabled = !(newPage == WizardPage.Page.WelcomePage) && !(newPage == WizardPage.Page.FinishPage); + ButtonPanel.Visible = !(newPage == WizardPage.Page.IsoCreationPage); + + Next_Button.Text = newPage == WizardPage.Page.FinishPage ? "Close" : "Next"; + + if (CurrentWizardPage.wizardPage == WizardPage.Page.IsoCreationPage) + { + if (isoSaverSFD.ShowDialog(this) != DialogResult.OK) + { + ChangePage(CurrentWizardPage.wizardPage - 1); + return; + } + AppState.SaveISO = isoSaverSFD.FileName; + RunDeployment(); + } + } + + private bool VerifyOptionsInPage(WizardPage.Page wizardPage) + { + switch (wizardPage) + { + case WizardPage.Page.IsoChooserPage: + if (String.IsNullOrEmpty(isoPathTB.Text) || !File.Exists(isoPathTB.Text)) + { + MessageBox.Show("Specify an ISO file and try again. Make sure that it exists", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + break; + case WizardPage.Page.ImageChooserPage: + if (AppState.SelectedImageIndex < 1) + { + MessageBox.Show("Please specify an image to modify and try again."); + return false; + } + // Store information about the selected image only. We can access it later if we see fit + installImageInfo = imageInfo.ElementAtOrDefault(AppState.SelectedImageIndex - 1); + break; + case WizardPage.Page.UserAccountsPage: + // Default to "User" if no name is set + if (String.IsNullOrEmpty(usrNameTB.Text)) + usrNameTB.Text = "User"; - pnlContent = new Panel { Dock = DockStyle.Fill }; - this.Controls.Add(pnlContent); + // Trim invalid characters from the user account + char[] invalidChars = ['/', '\\', '[', ']', ':', ';', '|', '=', ',', '+', '*', '?', '<', '>', '\"', '%']; + if (AppState.UserAccounts.Any()) + { + foreach (UserAccount account in AppState.UserAccounts) + { + account.Name = new string(account.Name.Where(c => !invalidChars.Contains(c)).ToArray()).TrimEnd('.'); + } + } + break; + } + return true; + } + + private void MainForm_Load(object sender, EventArgs e) + { + Text = $"MicroWin .NET ({swStatus} 0.2)"; - string disclaimerMessage = $"Thank you for trying this ALPHA release of MicroWin .NET.\n\n" + - $"Because this is an alpha version of a rewrite of the original PowerShell version, bugs may happen. We expect improvements in quality " + + string disclaimerMessage = $"Thank you for trying this {swStatus} release of MicroWin .NET.\n\n" + + $"Because this is a prerelease version of a rewrite of the original PowerShell version, bugs may happen. We expect improvements in quality " + $"as time goes on, but that can be done with your help. Report the bugs over on the GitHub repository.\n\n" + - $"This ALPHA release already has almost every feature implemented, besides a few that couldn't make it to this release. Those will be " + + $"This {swStatus} release already has almost every feature implemented, besides a few that couldn't make it to this release. Those will be " + $"implemented in future releases. Head over to the roadmap available in the repository for more info.\n\n" + $"Please disable your antivirus or set an exclusion to prevent conflicts. Do not worry, this is an open-source project and we take " + $"your computer's security seriously.\n\n" + $"Thanks,\n" + $"CWSOFTWARE and the rest of the team behind MicroWin."; - MessageBox.Show(disclaimerMessage, "ALPHA RELEASE", MessageBoxButtons.OK, MessageBoxIcon.Information); + lblDisclaimer.Text = disclaimerMessage; + + ChangePage(WizardPage.Page.WelcomePage); + + SetColorMode(); + + // Insert an item in there so we can work with it + AppState.UserAccounts.Add(new UserAccount() { Role = "Administrator" }); + + // Other default settings + DriverExportCombo.SelectedIndexChanged -= DriverExportCombo_SelectedIndexChanged; + DriverExportCombo.SelectedIndex = (int)AppState.DriverExportMode; + DriverExportCombo.SelectedIndexChanged += DriverExportCombo_SelectedIndexChanged; + } + + private void Next_Button_Click(object sender, EventArgs e) + { + if (CurrentWizardPage.wizardPage == WizardPage.Page.FinishPage) + { + Close(); + } + else + { + ChangePage(CurrentWizardPage.wizardPage + 1); + } + } + + private void Back_Button_Click(object sender, EventArgs e) + { + ChangePage(CurrentWizardPage.wizardPage - 1); + } + + private void isoPickerBtn_Click(object sender, EventArgs e) + { + isoPickerOFD.ShowDialog(this); + } + + private void isoPickerOFD_FileOk(object sender, System.ComponentModel.CancelEventArgs e) + { + isoPathTB.Text = isoPickerOFD.FileName; + } + + private void InvokeIsoExtractionUIUpdate(string status, int progress) + { + if (InvokeRequired) + { + Invoke(new Action(() => { + lblExtractionStatus.Text = $"Status: {status}"; + isoExtractionPB.Value = progress; + })); + } + else + { + lblExtractionStatus.Text = $"Status: {status}"; + isoExtractionPB.Value = progress; + } + } + + private void LoadWimData() + { + string wimPath = Path.Combine(AppState.MountPath, "sources", "install.wim"); + if (!File.Exists(wimPath)) wimPath = Path.Combine(AppState.MountPath, "sources", "install.esd"); + + if (File.Exists(wimPath)) + { + imageInfo = DismManager.GetImageInformation(wimPath); + if (imageInfo is null) + return; + + lvVersions.Items.Clear(); + lvVersions.Items.AddRange(imageInfo.Select(image => new ListViewItem([image.ImageIndex.ToString(), + image.ImageName, image.ImageDescription, + image.Architecture.ToString(), + image.CustomizedInfo?.ModifiedTime.ToString("dd/MM/yyyy HH:mm:ss")])).ToArray()); + if (imageInfo.Any()) + { + // Get and select Pro automatically + lvVersions.SelectedIndexChanged -= lvVersions_SelectedIndexChanged; + int? proIdx = imageInfo.FirstOrDefault(image => image.EditionId.Equals("Professional", StringComparison.OrdinalIgnoreCase))?.ImageIndex; + lvVersions.Items[proIdx - 1 ?? 0].Selected = true; + lvVersions.Select(); + lvVersions.SelectedIndexChanged += lvVersions_SelectedIndexChanged; + AppState.SelectedImageIndex = (proIdx ?? 1); + } + } + else + { + MessageBox.Show("Error: Image file not found in extraction folder."); + } + } + + private async void isoPathTB_TextChanged(object sender, EventArgs e) + { + if (File.Exists(isoPathTB.Text)) + { + isoPickerBtn.Enabled = false; + AppState.IsoPath = isoPathTB.Text; + BusyCannotClose = true; + + ButtonPanel.Enabled = false; + WindowHelper.DisableCloseCapability(Handle); + + await Task.Run(() => { + var iso = new IsoManager(); + InvokeIsoExtractionUIUpdate("Mounting ISO...", 5); + + char drive = iso.MountAndGetDrive(AppState.IsoPath); + if (drive != '\0') + { + iso.ExtractIso(drive.ToString(), AppState.MountPath, (p) => { + // Update the bar based on the 0-100 value from IsoManager + InvokeIsoExtractionUIUpdate($"Extracting: {p}%", p); + }); + + InvokeIsoExtractionUIUpdate("Dismounting...", 100); + iso.Dismount(AppState.IsoPath); + } + + InvokeIsoExtractionUIUpdate("Extraction complete. Click Next to continue.", 100); + }); + isoPickerBtn.Enabled = true; + BusyCannotClose = false; + ButtonPanel.Enabled = true; + WindowHelper.EnableCloseCapability(Handle); + } + } + + private void lvVersions_SelectedIndexChanged(object sender, EventArgs e) + { + if (lvVersions.SelectedItems.Count == 1) + AppState.SelectedImageIndex = lvVersions.FocusedItem.Index + 1; + } + + private void lnkImmersiveAccounts_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("ms-settings:otherusers"); + } + + private void lnkLusrMgr_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "system32", "lusrmgr.msc")); + } + + private void usrNameTB_TextChanged(object sender, EventArgs e) + { + AppState.UserAccounts[0].Name = usrNameTB.Text; + } + + private void b64CB_CheckedChanged(object sender, EventArgs e) + { + AppState.EncodeWithB64 = b64CB.Checked; + } + + private void usrPasswordTB_TextChanged(object sender, EventArgs e) + { + AppState.UserAccounts[0].Password = usrPasswordTB.Text; + } - // Start at the first page - ShowPage(new Page_SelectISO(this)); + private void usrNameCurrentSysNameBtn_Click(object sender, EventArgs e) + { + usrNameTB.Text = Environment.UserName; + } + + private void usrPasswordRevealCB_CheckedChanged(object sender, EventArgs e) + { + usrPasswordTB.PasswordChar = usrPasswordRevealCB.Checked ? '\0' : '*'; + } + + private void DriverExportCombo_SelectedIndexChanged(object sender, EventArgs e) + { + AppState.DriverExportMode = (DriverExportMode)DriverExportCombo.SelectedIndex; + } + + private void ReportToolCB_CheckedChanged(object sender, EventArgs e) + { + AppState.AddReportingToolShortcut = ReportToolCB.Checked; + } + + private void UnattendCopyCB_CheckedChanged(object sender, EventArgs e) + { + AppState.CopyUnattendToFileSystem = UnattendCopyCB.Checked; + } + + private void UpdateCurrentStatus(string text, bool resetBar = true) + { + if (InvokeRequired) + { + Invoke(new Action(() => + { + lblCurrentStatus.Text = text; + if (resetBar) pbCurrent.Value = 0; + })); + } + else + { + lblCurrentStatus.Text = text; + if (resetBar) pbCurrent.Value = 0; + } + } + + private void UpdateCurrentProgressBar(int value) + { + int safeValue = Math.Max(0, Math.Min(value, 100)); + if (this.InvokeRequired) this.Invoke(new Action(() => pbCurrent.Value = safeValue)); + else pbCurrent.Value = safeValue; + } + + private void UpdateOverallStatus(string text) + { + if (this.InvokeRequired) this.Invoke(new Action(() => { lblOverallStatus.Text = text; })); + else { lblOverallStatus.Text = text; } + } + + private void UpdateOverallProgressBar(int value) + { + int safeValue = Math.Max(0, Math.Min(value, 100)); + if (this.InvokeRequired) this.Invoke(new Action(() => pbOverall.Value = safeValue)); + else pbOverall.Value = safeValue; + } + + private void WriteLogMessage(string message) + { + string fullMsg = $"[{DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss")} UTC] {message}{Environment.NewLine}"; + if (InvokeRequired) + { + Invoke(new Action(() => logTB.AppendText(fullMsg))); + } + else + { + logTB.AppendText(fullMsg); + } + } + + private async void RunDeployment() + { + // Clear old results and write the cool banner + logTB.Clear(); + logTB.Text = @" + /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ + / \ | | / __|| '__| / _ \ \ \/ \/ /| || '_ \ + / /\/\ \| || (__ | | | (_) | \ /\ / | || | | | + \/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| + + MicroWin .NET (BETA 0.2) + +"; + + WindowHelper.DisableCloseCapability(Handle); + BusyCannotClose = true; + + await Task.Run(async () => { + string installwimPath = Path.Combine(AppState.MountPath, "sources", "install.wim"); + if (!File.Exists(installwimPath)) installwimPath = Path.Combine(AppState.MountPath, "sources", "install.esd"); + + UpdateOverallStatus("Customizing install image..."); + UpdateOverallProgressBar(0); + UpdateCurrentStatus("Mounting install image..."); + DismManager.MountImage(installwimPath, AppState.SelectedImageIndex, AppState.ScratchPath, (p) => UpdateCurrentProgressBar(p), (msg) => WriteLogMessage(msg)); + + WriteLogMessage("Creating unattended answer file..."); + UnattendGenerator.CreateUnattend($"{Path.Combine(AppState.ScratchPath, "Windows", "Panther")}"); + + UpdateOverallProgressBar(10); + new OsFeatureDisabler().RunTask((p) => UpdateCurrentProgressBar(p), (msg) => UpdateCurrentStatus(msg, false), (msg) => WriteLogMessage(msg)); + UpdateOverallProgressBar(20); + new OsPackageRemover().RunTask((p) => UpdateCurrentProgressBar(p), (msg) => UpdateCurrentStatus(msg, false), (msg) => WriteLogMessage(msg)); + UpdateOverallProgressBar(30); + new StoreAppRemover().RunTask((p) => UpdateCurrentProgressBar(p), (msg) => UpdateCurrentStatus(msg, false), (msg) => WriteLogMessage(msg)); + + UpdateOverallProgressBar(40); + WriteLogMessage("Loading image registry hives..."); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SOFTWARE"), "zSOFTWARE"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SYSTEM"), "zSYSTEM"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "default"), "zDEFAULT"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Users", "Default", "ntuser.dat"), "zNTUSER"); + + UpdateCurrentStatus("Modifying install image..."); + if (AppState.AddReportingToolShortcut) + { + WriteLogMessage("Downloading and integrating reporting tool..."); + using (var client = new HttpClient()) + { + var data = await client.GetByteArrayAsync("https://raw.githubusercontent.com/CodingWonders/MyScripts/refs/heads/main/MicroWinHelperTools/ReportingTool/ReportingTool.ps1"); + File.WriteAllBytes(Path.Combine(AppState.ScratchPath, "ReportingTool.ps1"), data); + } + + RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin"); + RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin", new RegistryItem("MicroWinVersion", ValueKind.REG_SZ, $"{AppState.Version}")); + RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin", new RegistryItem("MicroWinBuildDate", ValueKind.REG_SZ, $"{DateTime.Now}")); + + } + UpdateCurrentProgressBar(10); + + WriteLogMessage("Disabling WPBT..."); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\ControlSet001\\Control\\Session Manager", new RegistryItem("DisableWpbtExecution", ValueKind.REG_DWORD, 1)); + + // Skip first logon animation + WriteLogMessage("Disabling FLA..."); + RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", new RegistryItem("EnableFirstLogonAnimation", ValueKind.REG_DWORD, 0)); + + WriteLogMessage("Setting execution policies..."); + RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell", new RegistryItem("ExecutionPolicy", ValueKind.REG_SZ, "RemoteSigned")); + + if (VersionComparer.IsBetweenVersionRange(installImageInfo.ProductVersion, VersionComparer.VERCONST_WIN11_24H2, VersionComparer.VERCONST_WIN11_25H2)) + { + // TODO for now this is here only to show if the image is within that version range. Add the code to add AppRuntime.CBS as a dependency of FileExp. + WriteLogMessage("TEST: Touching up fileexp..."); + } + + UpdateCurrentProgressBar(50); + using (var client = new HttpClient()) + { + try + { + var data = client.GetByteArrayAsync("https://github.com/CodingWonders/MicroWin/raw/main/MicroWin/tools/FirstStartup.ps1").GetAwaiter().GetResult(); + File.WriteAllBytes(Path.Combine(AppState.ScratchPath, "Windows", "FirstStartup.ps1"), data); + } + catch { } + } + + UpdateCurrentProgressBar(90); + WriteLogMessage("Unloading image registry hives..."); + RegistryHelper.UnloadRegistryHive("zSYSTEM"); + RegistryHelper.UnloadRegistryHive("zSOFTWARE"); + RegistryHelper.UnloadRegistryHive("zDEFAULT"); + RegistryHelper.UnloadRegistryHive("zNTUSER"); + UpdateCurrentProgressBar(100); + + UpdateCurrentStatus("Unmounting install image..."); + DismManager.UnmountAndSave(AppState.ScratchPath.TrimEnd('\\'), (p) => UpdateCurrentProgressBar(p), (msg) => WriteLogMessage(msg)); + + UpdateOverallProgressBar(50); + + string bootwimPath = Path.Combine(AppState.MountPath, "sources", "boot.wim"); + if (!File.Exists(bootwimPath)) bootwimPath = Path.Combine(AppState.MountPath, "sources", "boot.esd"); + + UpdateOverallStatus("Customizing boot image..."); + UpdateCurrentStatus("Mounting boot image..."); + DismManager.MountImage(bootwimPath, 2, AppState.ScratchPath, (p) => UpdateCurrentProgressBar(p), (msg) => WriteLogMessage(msg)); + + UpdateCurrentStatus("Modifying WinPE registry..."); + WriteLogMessage("Loading image registry hives..."); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SOFTWARE"), "zSOFTWARE"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SYSTEM"), "zSYSTEM"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "default"), "zDEFAULT"); + RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Users", "Default", "ntuser.dat"), "zNTUSER"); + + UpdateCurrentProgressBar(50); + WriteLogMessage("Bypassing requirements..."); + RegistryHelper.AddRegistryItem("HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV1", ValueKind.REG_DWORD, 0)); + RegistryHelper.AddRegistryItem("HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV2", ValueKind.REG_DWORD, 0)); + RegistryHelper.AddRegistryItem("HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV1", ValueKind.REG_DWORD, 0)); + RegistryHelper.AddRegistryItem("HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV2", ValueKind.REG_DWORD, 0)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassCPUCheck", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassRAMCheck", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassSecureBootCheck", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassStorageCheck", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassTPMCheck", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\MoSetup", new RegistryItem("AllowUpgradesWithUnsupportedTPMOrCPU", ValueKind.REG_DWORD, 1)); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\Status\\ChildCompletion", new RegistryItem("setup.exe", ValueKind.REG_DWORD, 3)); + + // Old Setup should only be imposed on 24H2 and later (builds 26040 and later). Get this information + bool shouldUsePanther = false; + + DismImageInfoCollection bootImageInfo = DismManager.GetImageInformation(bootwimPath); + if (bootImageInfo is not null) + { + // Get the second index then get version + DismImageInfo setupImage = bootImageInfo.ElementAtOrDefault(1); + shouldUsePanther = VersionComparer.IsNewerThanVersion(setupImage?.ProductVersion, new(10, 0, 26040, 0)); + } + + if (shouldUsePanther) + { + UpdateCurrentProgressBar(75); + WriteLogMessage("Imposing old Setup..."); + RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup", new RegistryItem("CmdLine", ValueKind.REG_SZ, "\\sources\\setup.exe")); + } + + UpdateCurrentProgressBar(95); + WriteLogMessage("Unloading image registry hives..."); + RegistryHelper.UnloadRegistryHive("zSYSTEM"); + RegistryHelper.UnloadRegistryHive("zSOFTWARE"); + RegistryHelper.UnloadRegistryHive("zDEFAULT"); + RegistryHelper.UnloadRegistryHive("zNTUSER"); + + UpdateCurrentStatus("Unmounting boot image..."); + DismManager.UnmountAndSave(AppState.ScratchPath.TrimEnd('\\'), (p) => UpdateCurrentProgressBar(p), (msg) => WriteLogMessage(msg)); + + UpdateOverallStatus("Generating ISO file..."); + UpdateOverallProgressBar(90); + UpdateCurrentStatus("Generating ISO file..."); + OscdimgUtilities.checkoscdImg(); + + UpdateOverallStatus("Finishing up..."); + UpdateOverallProgressBar(95); + UpdateCurrentStatus("Finishing up..."); + WriteLogMessage("Deleting temporary files..."); + DeleteFiles.SafeDeleteDirectory(AppState.TempRoot); + }); + + WindowHelper.EnableCloseCapability(Handle); + WriteLogMessage("Finished."); + UpdateCurrentStatus("Generation complete"); + UpdateOverallProgressBar(100); + UpdateCurrentProgressBar(100); + BusyCannotClose = false; + ChangePage(WizardPage.Page.FinishPage); + } + + private void lnkUseDT_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://github.com/CodingWonders/DISMTools"); + } + + private void lnkUseNtLite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://ntlite.com"); + } + + private void lnkOpenIsoLoc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"), + $"/select,\"{AppState.SaveISO}\""); + } + + private void MainForm_SizeChanged(object sender, EventArgs e) + { + if (BusyCannotClose) + WindowHelper.DisableCloseCapability(Handle); + else + WindowHelper.EnableCloseCapability(Handle); } - public void ShowPage(UserControl page) + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { - pnlContent.Controls.Clear(); - page.Dock = DockStyle.Fill; - pnlContent.Controls.Add(page); + if (BusyCannotClose) + { + e.Cancel = true; + return; + } } } } \ No newline at end of file diff --git a/MicroWin/MainForm.resx b/MicroWin/MainForm.resx new file mode 100644 index 0000000..1d00b7b --- /dev/null +++ b/MicroWin/MainForm.resx @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + To continue with OS installation, use a tool to create bootable USB drives, such as Rufus or Ventoy, and install the system. + +If you want to continue customizing this system, use either of the following: + + + Enter the information that will be used to create the first user account on the target system. Additional users can be created later. You can skip entering this information. In that case, default values will be used. + + + 17, 17 + + + 141, 17 + + \ No newline at end of file diff --git a/MicroWin/MicroWin.csproj b/MicroWin/MicroWin.csproj index 7dba702..f40cb09 100755 --- a/MicroWin/MicroWin.csproj +++ b/MicroWin/MicroWin.csproj @@ -1,6 +1,5 @@ - Debug @@ -59,6 +58,9 @@ app.manifest + + MicroWin.Program + ..\packages\Microsoft.Dism.4.0.7\lib\net40\Microsoft.Dism.dll @@ -77,6 +79,8 @@ + + @@ -84,12 +88,15 @@ + + + Form @@ -99,9 +106,9 @@ - - UserControl - + + MainForm.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -142,6 +149,8 @@ + + diff --git a/MicroWin/Properties/AssemblyInfo.cs b/MicroWin/Properties/AssemblyInfo.cs index 3e1b232..ff951c7 100755 --- a/MicroWin/Properties/AssemblyInfo.cs +++ b/MicroWin/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.2.0.0")] +[assembly: AssemblyFileVersion("0.2.0.0")] diff --git a/MicroWin/Properties/Resources.Designer.cs b/MicroWin/Properties/Resources.Designer.cs index 6a82555..1d2110f 100755 --- a/MicroWin/Properties/Resources.Designer.cs +++ b/MicroWin/Properties/Resources.Designer.cs @@ -59,5 +59,25 @@ internal Resources() { resourceCulture = value; } } + + /// + /// Busca un recurso adaptado de tipo System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap user_creation_lusrmgr { + get { + object obj = ResourceManager.GetObject("user_creation_lusrmgr", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Busca un recurso adaptado de tipo System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap user_creation_settings { + get { + object obj = ResourceManager.GetObject("user_creation_settings", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/MicroWin/Properties/Resources.resx b/MicroWin/Properties/Resources.resx index ffecec8..828f75d 100755 --- a/MicroWin/Properties/Resources.resx +++ b/MicroWin/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\user_creation_lusrmgr.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\user_creation_settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/MicroWin/Resources/user_creation_lusrmgr.png b/MicroWin/Resources/user_creation_lusrmgr.png new file mode 100644 index 0000000..ac00ba6 Binary files /dev/null and b/MicroWin/Resources/user_creation_lusrmgr.png differ diff --git a/MicroWin/Resources/user_creation_settings.png b/MicroWin/Resources/user_creation_settings.png new file mode 100644 index 0000000..b313e23 Binary files /dev/null and b/MicroWin/Resources/user_creation_settings.png differ diff --git a/MicroWin/WizardPages.cs b/MicroWin/WizardPages.cs deleted file mode 100755 index e9f11ff..0000000 --- a/MicroWin/WizardPages.cs +++ /dev/null @@ -1,412 +0,0 @@ -using Microsoft.Dism; -using MicroWin.functions.dism; -using MicroWin.functions.Helpers.DeleteFile; -using MicroWin.functions.Helpers.RegistryHelpers; -using MicroWin.functions.iso; -using MicroWin.OSCDIMG; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace MicroWin -{ - /* TODO: Use this as the logo (in Courier New) - * - * /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ - * / \ | | / __|| '__| / _ \ \ \/ \/ /| || '_ \ - * / /\/\ \| || (__ | | | (_) | \ /\ / | || | | | - * \/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| - * - */ - - - // --- PAGE 1: SELECT ISO --- - public class Page_SelectISO : UserControl - { - private MainForm _parent; - private Label lblStatus; - private ProgressBar pb; - - public Page_SelectISO(MainForm main) - { - _parent = main; - var lbl = new Label { Text = "Step 1: Select Windows ISO", Location = new Point(50, 30), AutoSize = true, Font = new Font("Arial", 12, FontStyle.Bold) }; - var btn = new Button { Text = "Browse ISO", Location = new Point(50, 60), Size = new Size(120, 30) }; - - lblStatus = new Label { Text = "Status: Ready", Location = new Point(50, 100), AutoSize = true }; - - // The Progress Bar - pb = new ProgressBar - { - Location = new Point(50, 130), - Size = new Size(400, 20), - Minimum = 0, - Maximum = 100, - Visible = false - }; - - btn.Click += async (s, e) => { - if (Directory.Exists(AppState.TempRoot)) - { - DeleteFiles.SafeDeleteDirectory(AppState.TempRoot); - } - - using (OpenFileDialog ofd = new OpenFileDialog { Filter = "ISO Files|*.iso" }) - { - if (ofd.ShowDialog() == DialogResult.OK) - { - btn.Enabled = false; - pb.Visible = true; - AppState.IsoPath = ofd.FileName; - - await Task.Run(() => { - var iso = new IsoManager(); - UpdateUI("Mounting ISO...", 5); - - char drive = iso.MountAndGetDrive(AppState.IsoPath); - if (drive != '\0') - { - iso.ExtractIso(drive.ToString(), AppState.MountPath, (p) => { - // Update the bar based on the 0-100 value from IsoManager - UpdateUI($"Extracting: {p}%", p); - }); - - UpdateUI("Dismounting...", 100); - iso.Dismount(AppState.IsoPath); - } - }); - - _parent.ShowPage(new Page_WinVersion(_parent)); - } - } - }; - this.Controls.AddRange(new Control[] { lbl, btn, lblStatus, pb }); - } - - private void UpdateUI(string status, int progress) - { - if (this.InvokeRequired) - { - this.Invoke(new Action(() => { - lblStatus.Text = $"Status: {status}"; - pb.Value = progress; - })); - } - else - { - lblStatus.Text = $"Status: {status}"; - pb.Value = progress; - } - } - } - - // --- PAGE 2: SELECT WINDOWS VERSION --- - public class Page_WinVersion : UserControl - { - private MainForm _parent; - private ListBox lstVersions; - - public Page_WinVersion(MainForm main) - { - _parent = main; - var lbl = new Label { Text = "Step 2: Select Windows Version", Location = new Point(50, 20), AutoSize = true }; - lstVersions = new ListBox { Location = new Point(50, 50), Size = new Size(350, 200) }; - var btnNext = new Button { Text = "Next", Location = new Point(50, 270), Size = new Size(100, 30) }; - - btnNext.Click += (s, e) => { - if (lstVersions.SelectedIndex != -1) - { - AppState.SelectedImageIndex = lstVersions.SelectedIndex + 1; - _parent.ShowPage(new Page_SetupType(_parent)); - } - }; - - this.Controls.AddRange(new Control[] { lbl, lstVersions, btnNext }); - - // Important: Handle the Load event to ensure files exist before reading - this.Load += (s, e) => LoadWimData(); - } - - private void LoadWimData() - { - string wimPath = Path.Combine(AppState.MountPath, "sources", "install.wim"); - if (!File.Exists(wimPath)) wimPath = Path.Combine(AppState.MountPath, "sources", "install.esd"); - - if (File.Exists(wimPath)) - { - Dictionary versions = DismManager.GetWimVersions(wimPath); - lstVersions.Items.Clear(); - lstVersions.Items.AddRange(versions.Select(kvp => String.Format("{0}: {1}", kvp.Key, kvp.Value)).ToArray()); - } - else - { - MessageBox.Show("Error: Image file not found in extraction folder."); - } - } - } - - // --- PAGE 3: SETUP TYPE --- - public class Page_SetupType : UserControl - { - private MainForm _parent; - public Page_SetupType(MainForm main) - { - _parent = main; - var btnAuto = new Button { Text = "Auto Setup (Automated OOBE)", Location = new Point(50, 80), Size = new Size(200, 40) }; - btnAuto.Click += (s, e) => { AppState.IsAuto = true; _parent.ShowPage(new Page_Users(_parent)); }; - this.Controls.Add(btnAuto); - } - } - - // --- PAGE 4: USERS (TABLE VIEW) --- - public class Page_Users : UserControl - { - private MainForm _parent; - private DataGridView grid; - - public Page_Users(MainForm main) - { - _parent = main; - var txtUser = new TextBox { Location = new Point(20, 40), Width = 100 }; - var txtPass = new TextBox { Location = new Point(130, 40), Width = 100, PasswordChar = '*' }; - var cmbRole = new ComboBox { Location = new Point(240, 40), Width = 100 }; - cmbRole.Items.AddRange(new string[] { "Administrator", "User" }); - cmbRole.SelectedIndex = 0; - - var btnAdd = new Button { Text = "Add", Location = new Point(350, 38) }; - grid = new DataGridView { Location = new Point(20, 80), Size = new Size(500, 150), AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill, AllowUserToAddRows = false }; - grid.Columns.Add("U", "User"); grid.Columns.Add("P", "Password"); grid.Columns.Add("R", "Role"); - - btnAdd.Click += (s, e) => { - if (!string.IsNullOrEmpty(txtUser.Text)) - { - AppState.UserAccounts.Add(new UserAccount { Name = txtUser.Text, Password = txtPass.Text, Role = cmbRole.Text }); - grid.Rows.Add(txtUser.Text, "********", cmbRole.Text); - txtUser.Clear(); txtPass.Clear(); - } - }; - - var btnNext = new Button { Text = "Next", Location = new Point(20, 250) }; - btnNext.Click += (s, e) => _parent.ShowPage(new Page_Tools(_parent)); - this.Controls.AddRange(new Control[] { txtUser, txtPass, cmbRole, btnAdd, grid, btnNext }); - } - } - - // --- PAGE 5: TOOLS & SHORTCUTS --- - public class Page_Tools : UserControl - { - private MainForm _parent; - public Page_Tools(MainForm main) - { - _parent = main; - var chkReport = new CheckBox { Text = "Add Reporting Tool Shortcut", Location = new Point(50, 80), AutoSize = true }; - var btnNext = new Button { Text = "Deploy Image", Location = new Point(50, 150), Size = new Size(150, 40), BackColor = Color.LightGreen }; - - btnNext.Click += (s, e) => { - AppState.AddReportingToolShortcut = chkReport.Checked; - _parent.ShowPage(new Page_Save(_parent)); - }; - this.Controls.AddRange(new Control[] { chkReport, btnNext }); - } - } - - // --- PAGE 6: Save --- - public class Page_Save : UserControl - { - private MainForm _parent; - public Page_Save(MainForm main) - { - _parent = main; - - var lbl = new Label { Text = "Save ISO", Location = new Point(50, 30), AutoSize = true, Font = new Font("Arial", 12, FontStyle.Bold) }; - var btn = new Button { Text = "Browse", Location = new Point(50, 60), Size = new Size(120, 30) }; - - btn.Click += (s, e) => { - using (SaveFileDialog ofd = new SaveFileDialog { - Filter = "ISO Files|*.iso", - FileName = "MicroWin.iso" - }) - { - if (ofd.ShowDialog() == DialogResult.OK) - { - AppState.saveISO = ofd.FileName; - _parent.ShowPage(new Page_Progress(_parent)); - } - } - }; - this.Controls.AddRange(new Control[] { lbl, btn }); - } - - } - - // --- PAGE 7: PROGRESS & DEPLOYMENT --- - public class Page_Progress : UserControl - { - private Label lblStatus; - private ProgressBar pb; - private MainForm _main; - - public Page_Progress(MainForm main) - { - _main = main; - lblStatus = new Label { Text = "Initializing...", Location = new Point(50, 50), Width = 400, AutoSize = true }; - pb = new ProgressBar { Location = new Point(50, 80), Size = new Size(400, 25), Style = ProgressBarStyle.Continuous }; - this.Controls.AddRange(new Control[] { lblStatus, pb }); - RunDeployment(); - } - - private void UpdateStatus(string text) - { - if (this.InvokeRequired) this.Invoke(new Action(() => { lblStatus.Text = text; pb.Value = 0; })); - else { lblStatus.Text = text; pb.Value = 0; } - } - - private void UpdateProgressBar(int value) - { - int safeValue = Math.Max(0, Math.Min(value, 100)); - if (this.InvokeRequired) this.Invoke(new Action(() => pb.Value = safeValue)); - else pb.Value = safeValue; - } - - private async void RunDeployment() - { - await Task.Run(async () => { - string installwimPath = Path.Combine(AppState.MountPath, "sources", "install.wim"); - if (!File.Exists(installwimPath)) installwimPath = Path.Combine(AppState.MountPath, "sources", "install.esd"); - - UpdateStatus("Mounting Install WIM..."); - DismManager.MountImage(installwimPath, AppState.SelectedImageIndex, AppState.ScratchPath, (p) => UpdateProgressBar(p)); - - UnattendGenerator.CreateUnattend($"{Path.Combine(AppState.ScratchPath, "Windows", "Panther")}"); - - new OsFeatureDisabler().RunTask(); - new OsPackageRemover().RunTask(); - new StoreAppRemover().RunTask(); - - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SOFTWARE"), "zSOFTWARE"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SYSTEM"), "zSYSTEM"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "default"), "zDEFAULT"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Users", "Default", "ntuser.dat"), "zNTUSER"); - - if (AppState.AddReportingToolShortcut) - { - using (var client = new HttpClient()) - { - var data = await client.GetByteArrayAsync("https://raw.githubusercontent.com/CodingWonders/MyScripts/refs/heads/main/MicroWinHelperTools/ReportingTool/ReportingTool.ps1"); - File.WriteAllBytes(Path.Combine(AppState.ScratchPath, "ReportingTool.ps1"), data); - } - - RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin"); - RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin", new RegistryItem("MicroWinVersion", ValueKind.REG_SZ, $"{AppState.Version}")); - RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\MicroWin", new RegistryItem("MicroWinBuildDate", ValueKind.REG_SZ, $"{DateTime.Now}")); - - } - - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\ControlSet001\\Control\\Session Manager", new RegistryItem("DisableWpbtExecution", ValueKind.REG_DWORD, 1)); - - // Skip first logon animation - RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", new RegistryItem("EnableFirstLogonAnimation", ValueKind.REG_DWORD, 0)); - - RegistryHelper.AddRegistryItem("HKLM\\zSOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell", new RegistryItem("ExecutionPolicy", ValueKind.REG_SZ, "RemoteSigned")); - - // int majorver = Convert.ToInt32(RegistryHelper.QueryRegistryValue("HKLM\\zSOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentMajorVersionNumber")); - // int minorver = Convert.ToInt32(RegistryHelper.QueryRegistryValue("HKLM\\zSOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentMinorVersionNumber")); - // string build = Convert.ToString(RegistryHelper.QueryRegistryValue("HKLM\\zSOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild")); - // string ubr = Convert.ToString(RegistryHelper.QueryRegistryValue("HKLM\\zSOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR")); - - //if (majorver == 10 && minorver == 0 && build == "26100" && ubr == "1") - //{ - //try - //{ - //DismApi.Initialize(DismLogLevel.LogErrors); - //using DismSession session = DismApi.OpenOfflineSession(AppState.ScratchPath); - - //DismApi.EnableFeature(session, "Recall", false, true); - //DismApi.Shutdown(); - //} - //catch - //{ - // Add logging - //} - //} - - using (var client = new HttpClient()) - { - try - { - var data = client.GetByteArrayAsync("https://github.com/CodingWonders/MicroWin/raw/main/MicroWin/tools/FirstStartup.ps1").GetAwaiter().GetResult(); - File.WriteAllBytes(Path.Combine(AppState.ScratchPath, "Windows", "FirstStartup.ps1"), data); - } - catch { } - } - - RegistryHelper.UnloadRegistryHive("zSYSTEM"); - RegistryHelper.UnloadRegistryHive("zSOFTWARE"); - RegistryHelper.UnloadRegistryHive("zDEFAULT"); - RegistryHelper.UnloadRegistryHive("zNTUSER"); - - UpdateStatus("Finalizing..."); - DismManager.UnmountAndSave(AppState.ScratchPath.TrimEnd('\\'), (p) => UpdateProgressBar(p)); - - string bootwimPath = Path.Combine(AppState.MountPath, "sources", "boot.wim"); - if (!File.Exists(bootwimPath)) bootwimPath = Path.Combine(AppState.MountPath, "sources", "boot.esd"); - - UpdateStatus("Mounting Boot WIM..."); - DismManager.MountImage(bootwimPath, 2, AppState.ScratchPath, (p) => UpdateProgressBar(p)); - - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SOFTWARE"), "zSOFTWARE"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "SYSTEM"), "zSYSTEM"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Windows", "System32", "config", "default"), "zDEFAULT"); - RegistryHelper.LoadRegistryHive(Path.Combine(AppState.ScratchPath, "Users", "Default", "ntuser.dat"), "zNTUSER"); - - RegistryHelper.AddRegistryItem("HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV1", ValueKind.REG_DWORD, 0)); - RegistryHelper.AddRegistryItem("HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV2", ValueKind.REG_DWORD, 0)); - RegistryHelper.AddRegistryItem("HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV1", ValueKind.REG_DWORD, 0)); - RegistryHelper.AddRegistryItem("HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache", new RegistryItem("SV2", ValueKind.REG_DWORD, 0)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassCPUCheck", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassRAMCheck", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassSecureBootCheck", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassStorageCheck", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\LabConfig", new RegistryItem("BypassTPMCheck", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\MoSetup", new RegistryItem("AllowUpgradesWithUnsupportedTPMOrCPU", ValueKind.REG_DWORD, 1)); - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup\\Status\\ChildCompletion", new RegistryItem("setup.exe", ValueKind.REG_DWORD, 3)); - - RegistryHelper.AddRegistryItem("HKLM\\zSYSTEM\\Setup", new RegistryItem("CmdLine", ValueKind.REG_SZ, "\\sources\\setup.exe")); - - RegistryHelper.UnloadRegistryHive("zSYSTEM"); - RegistryHelper.UnloadRegistryHive("zSOFTWARE"); - RegistryHelper.UnloadRegistryHive("zDEFAULT"); - RegistryHelper.UnloadRegistryHive("zNTUSER"); - - UpdateStatus("Finalizing..."); - DismManager.UnmountAndSave(AppState.ScratchPath.TrimEnd('\\'), (p) => UpdateProgressBar(p)); - - OscdimgUtilities.checkoscdImg(); - - Console.Write(AppState.saveISO); - - DeleteFiles.SafeDeleteDirectory(AppState.TempRoot); - }); - - _main.ShowPage(new Page_Finish(_main)); - } - } - - // --- PAGE 8: FINISH --- - public class Page_Finish : UserControl - { - public Page_Finish(MainForm main) - { - var lbl = new Label { Text = "Finished!", Location = new Point(50, 50), AutoSize = true }; - var btnClose = new Button { Text = "Close", Location = new Point(50, 100) }; - btnClose.Click += (s, e) => Application.Exit(); - this.Controls.AddRange(new Control[] { lbl, btnClose }); - } - } - -} diff --git a/MicroWin/functions/Helpers/DesktopWindowManager/WindowHelper.cs b/MicroWin/functions/Helpers/DesktopWindowManager/WindowHelper.cs new file mode 100644 index 0000000..8e474c7 --- /dev/null +++ b/MicroWin/functions/Helpers/DesktopWindowManager/WindowHelper.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using System.Drawing; +using System.Runtime.Remoting.Messaging; + +namespace MicroWin.functions.Helpers.DesktopWindowManager +{ + public class WindowHelper + { + public sealed class NativeMethods + { + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); + + [DllImport("dwmapi.dll")] + public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); + } + + // User32 constants + const int SC_CLOSE = 0xF060; + const long MF_BYCOMMAND = 0; + const long MF_ENABLED = 0; + const long MF_GRAYED = 1; + const long MF_DISABLED = 2; + + // DwmApi constants + const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; + const int WS_EX_COMPOSITED = 0x2000000; + const int GWL_EXSTYLE = -20; + + public static void DisableCloseCapability(IntPtr wndHandle) + { + if (!wndHandle.Equals(IntPtr.Zero)) + { + IntPtr menu = NativeMethods.GetSystemMenu(wndHandle, false); + if (!menu.Equals(IntPtr.Zero)) + NativeMethods.EnableMenuItem(menu, SC_CLOSE, (uint)(MF_BYCOMMAND | MF_GRAYED | MF_DISABLED)); + } + } + + public static void EnableCloseCapability(IntPtr wndHandle) + { + if (!wndHandle.Equals(IntPtr.Zero)) + { + IntPtr menu = NativeMethods.GetSystemMenu(wndHandle, false); + if (!menu.Equals(IntPtr.Zero)) + NativeMethods.EnableMenuItem(menu, SC_CLOSE, (uint)(MF_BYCOMMAND | MF_ENABLED)); + } + } + + public static IntPtr? GetWindowHandleFromControl(Control ctrl) + { + return ctrl?.Handle; + } + + const int DARKMODE_MINMAJOR = 10; + const int DARKMODE_MINMINOR = 0; + const int DARKMODE_MINBUILD = 18362; + + public static void ToggleDarkTitleBar(IntPtr hwnd, bool darkMode) + { + int attribute = darkMode ? 1 : 0; + if (!IsWindowsVersionOrGreater(DARKMODE_MINMAJOR, DARKMODE_MINMINOR, DARKMODE_MINBUILD)) + return; + int result = NativeMethods.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, ref attribute, 4); + } + + private static bool IsWindowsVersionOrGreater(int majorVersion, int minorVersion, int buildNumber) + { + Version version = Environment.OSVersion.Version; + return version.Major > majorVersion || + (version.Major == majorVersion && version.Minor > minorVersion) || + (version.Major == majorVersion && version.Minor == minorVersion && version.Build >= buildNumber); + } + + public static int ScaleLogical(int px) + { + Single dx; + Control control = new(); + Graphics g = control.CreateGraphics(); + + try + { + dx = g.DpiX; + } + finally + { + g.Dispose(); + } + + return (int)(px * (dx / 96.0)); + } + + public static Point ScalePositionLogical(int posX, int posY) + { + return new Point(ScaleLogical(posX), ScaleLogical(posY)); + } + + public static Size ScaleSizeLogical(int width, int height) + { + return new Size(ScaleLogical(width), ScaleLogical(height)); + } + + public static Single GetSystemDpi() + { + return (Single)ScaleLogical(100); + } + + public static void DisplayToolTip(object tooltipSender, string tooltipMessage) + { + if (tooltipSender is Control ctrl) + { + ToolTip displayedToolTip = new(); + displayedToolTip.SetToolTip(ctrl, tooltipMessage); + } + } + } +} diff --git a/MicroWin/functions/Helpers/PropertyCheckers/VersionComparer.cs b/MicroWin/functions/Helpers/PropertyCheckers/VersionComparer.cs new file mode 100644 index 0000000..840d6c4 --- /dev/null +++ b/MicroWin/functions/Helpers/PropertyCheckers/VersionComparer.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MicroWin.functions.Helpers.PropertyCheckers +{ + public static class VersionComparer + { + public static readonly Version VERCONST_WIN10_22H2 = new(10, 0, 19045, 2130); + public static readonly Version VERCONST_WIN11_21H2 = new(10, 0, 22000, 194); + public static readonly Version VERCONST_WIN11_22H2 = new(10, 0, 22621, 382); + public static readonly Version VERCONST_WIN11_23H2 = new(10, 0, 22631, 2428); + public static readonly Version VERCONST_WIN11_24H2 = new(10, 0, 26100, 1742); + public static readonly Version VERCONST_WIN11_25H2 = new(10, 0, 26200, 6584); + public static readonly Version VERCONST_WIN11_26H1 = new(10, 0, 28000, 1575); + + public static bool IsNewerThanVersion(Version versionToCompare, Version minimumThreshold) + { + return versionToCompare >= minimumThreshold; + } + + public static bool IsOlderThanVersion(Version versionToCompare, Version maximumThreshold) + { + return versionToCompare < maximumThreshold; + } + + public static bool IsBetweenVersionRange(Version versionToCompare, Version lowerBound, Version upperBound) + { + return (versionToCompare >= lowerBound) && (versionToCompare < upperBound); + } + } +} diff --git a/MicroWin/functions/OSCDIMG/OscdimgUtilities.cs b/MicroWin/functions/OSCDIMG/OscdimgUtilities.cs index 7eb87fa..34ad15e 100644 --- a/MicroWin/functions/OSCDIMG/OscdimgUtilities.cs +++ b/MicroWin/functions/OSCDIMG/OscdimgUtilities.cs @@ -52,7 +52,7 @@ public static void startInstall() StartInfo = new ProcessStartInfo() { FileName = oscdimgPath, - Arguments = $"-m -o -u2 -udfver102 -bootdata:2#p0,e,b{Path.Combine(AppState.MountPath, "boot", "etfsboot.com")}#pEF,e,b{Path.Combine(AppState.MountPath, "efi", "microsoft", "boot", "efisys.bin")} \"{AppState.MountPath}\" \"{AppState.saveISO}\"" + Arguments = $"-m -o -u2 -udfver102 -bootdata:2#p0,e,b{Path.Combine(AppState.MountPath, "boot", "etfsboot.com")}#pEF,e,b{Path.Combine(AppState.MountPath, "efi", "microsoft", "boot", "efisys.bin")} \"{AppState.MountPath}\" \"{AppState.SaveISO}\"" } }; oscdimgProc.Start(); diff --git a/MicroWin/functions/UI/WizardPage.cs b/MicroWin/functions/UI/WizardPage.cs new file mode 100644 index 0000000..552eeb6 --- /dev/null +++ b/MicroWin/functions/UI/WizardPage.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MicroWin.functions.UI +{ + public class WizardPage + { + public enum Page : int + { + WelcomePage = 0, + IsoChooserPage = 1, + ImageChooserPage = 2, + UserAccountsPage = 3, + IsoSettingsPage = 4, + IsoCreationPage = 5, + FinishPage = 6 + } + + public Page wizardPage { get; set; } + + public const int PageCount = 7; + + } +} diff --git a/MicroWin/functions/dism/DismManager.cs b/MicroWin/functions/dism/DismManager.cs index f1e9808..b83f672 100755 --- a/MicroWin/functions/dism/DismManager.cs +++ b/MicroWin/functions/dism/DismManager.cs @@ -1,36 +1,22 @@ using Microsoft.Dism; +using MicroWin.functions.Helpers.Loggers; using System; using System.CodeDom; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; namespace MicroWin.functions.dism { public static class DismManager { - public static Dictionary GetWimVersions(string wimPath) - { - Dictionary versions = new Dictionary(); - - DismImageInfoCollection imageInfoCollection = GetImageInformation(wimPath); - if (imageInfoCollection is null) - return versions; - - foreach (DismImageInfo imageInfo in imageInfoCollection) - { - versions.Add(imageInfo.ImageIndex, imageInfo.ImageName); - } - - return versions; - } - - public static void MountImage(string wimPath, int index, string mountPath, Action progress) + public static void MountImage(string wimPath, int index, string mountPath, Action progress, Action logMessage) { // Check whether the file exists, then the index, then the mount path. - + logMessage.Invoke($"Preparing to mount image {Path.GetFileName(wimPath)} (index {index})..."); if (!File.Exists(wimPath)) return; @@ -53,23 +39,26 @@ public static void MountImage(string wimPath, int index, string mountPath, Actio // exception. if ((File.GetAttributes(wimPath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { + DynaLog.logMessage("Removing readonly..."); File.SetAttributes(wimPath, (File.GetAttributes(wimPath) & ~FileAttributes.ReadOnly)); } try { + logMessage.Invoke("Beginning mount operation..."); DismApi.Initialize(DismLogLevel.LogErrors); DismApi.MountImage(wimPath, mountPath, index, false, DismMountImageOptions.None, (currentProgress) => { progress(currentProgress.Current); }); } - catch (Exception) + catch (Exception ex) { - + DynaLog.logMessage($"Image could not be mounted. Message: {ex.Message}"); } finally { + logMessage.Invoke("Finishing mount operation..."); try { DismApi.Shutdown(); @@ -110,7 +99,7 @@ private static DismMountedImageInfoCollection GetMountedImages() return mountedImages; } - private static DismImageInfoCollection GetImageInformation(string wimFile) + public static DismImageInfoCollection GetImageInformation(string wimFile) { DismImageInfoCollection imageInfo = null; @@ -138,8 +127,9 @@ private static DismImageInfoCollection GetImageInformation(string wimFile) return imageInfo; } - public static void UnmountAndSave(string mountPath, Action progress) + public static void UnmountAndSave(string mountPath, Action progress, Action logMessage) { + logMessage.Invoke($"Preparing to unmount image..."); if (!Directory.Exists(mountPath)) { // TODO log this; we immediately return if it doesn't exist. @@ -157,6 +147,7 @@ public static void UnmountAndSave(string mountPath, Action progress) { DismApi.Initialize(DismLogLevel.LogErrors); + logMessage.Invoke($"Saving and unmounting image..."); DismProgressCallback progressCallback = (currentProgress) => { int scaledProgress = (currentProgress.Current / 2); diff --git a/MicroWin/functions/dism/ImageModificationTask.cs b/MicroWin/functions/dism/ImageModificationTask.cs index ef8fb15..51bdd76 100644 --- a/MicroWin/functions/dism/ImageModificationTask.cs +++ b/MicroWin/functions/dism/ImageModificationTask.cs @@ -10,6 +10,6 @@ public abstract class ImageModificationTask { public virtual List excludedItems { get; protected set; } = []; - public abstract void RunTask(); + public abstract void RunTask(Action pbReporter, Action curOpReporter, Action logWriter); } } diff --git a/MicroWin/functions/dism/OsFeatureDisabler.cs b/MicroWin/functions/dism/OsFeatureDisabler.cs index 9b1a538..de4ea96 100644 --- a/MicroWin/functions/dism/OsFeatureDisabler.cs +++ b/MicroWin/functions/dism/OsFeatureDisabler.cs @@ -25,34 +25,47 @@ public override List excludedItems { "RemoteDesktop" ]; - public override void RunTask() + public override void RunTask(Action pbReporter, Action curOpReporter, Action logWriter) { - DisableFeatures(); + DisableFeatures(pbReporter, curOpReporter, logWriter); } - private void DisableFeatures() + private void DisableFeatures(Action pbReporter, Action curOpReporter, Action logWriter) { + curOpReporter.Invoke("Getting image features..."); DismFeatureCollection allFeatures = GetFeatureList(); + if (allFeatures is null) return; + + logWriter.Invoke($"Amount of features in image: {allFeatures.Count}"); + + curOpReporter.Invoke("Filtering image features..."); IEnumerable featuresToDisable = allFeatures .Where(feature => ! new DismPackageFeatureState[3] { DismPackageFeatureState.NotPresent, DismPackageFeatureState.UninstallPending, DismPackageFeatureState.Staged }.Contains(feature.State)) .Select(feature => feature.FeatureName) .Where(feature => !excludedItems.Any(entry => feature.IndexOf(entry, StringComparison.OrdinalIgnoreCase) >= 0)); + logWriter.Invoke($"Features to disable: {featuresToDisable.Count()}"); + try { DismApi.Initialize(DismLogLevel.LogErrors); using DismSession session = DismApi.OpenOfflineSession(AppState.ScratchPath); + int idx = 0; foreach (string featureToDisable in featuresToDisable) { + curOpReporter.Invoke($"Disabling feature {featureToDisable}..."); + pbReporter.Invoke((int)(((double)idx / featuresToDisable.ToList().Count) * 100)); try { DismApi.DisableFeature(session, featureToDisable, null, true); } catch (Exception ex) { + logWriter.Invoke($"Feature {featureToDisable} could not be disabled: {ex.Message}"); DynaLog.logMessage($"ERROR: Failed to disable {featureToDisable}: {ex.Message}"); } + idx++; } } catch (Exception) @@ -61,6 +74,7 @@ private void DisableFeatures() } finally { + pbReporter.Invoke(100); try { DismApi.Shutdown(); diff --git a/MicroWin/functions/dism/OsPackageRemover.cs b/MicroWin/functions/dism/OsPackageRemover.cs index d7267ca..e2b65b0 100644 --- a/MicroWin/functions/dism/OsPackageRemover.cs +++ b/MicroWin/functions/dism/OsPackageRemover.cs @@ -35,26 +35,35 @@ public override List excludedItems "PMCPPC" ]; - public override void RunTask() + public override void RunTask(Action pbReporter, Action curOpReporter, Action logWriter) { - RemoveUnwantedPackages(); + RemoveUnwantedPackages(pbReporter, curOpReporter, logWriter); } - private void RemoveUnwantedPackages() + private void RemoveUnwantedPackages(Action pbReporter, Action curOpReporter, Action logWriter) { + curOpReporter.Invoke("Getting image packages..."); DismPackageCollection allPackages = GetPackageList(); - List selectedNames = AppState.SelectedPackages.ToList(); + if (allPackages is null) return; + logWriter.Invoke($"Amount of packages in image: {allPackages.Count}"); + + curOpReporter.Invoke("Filtering image packages..."); IEnumerable packagesToRemove = allPackages.Select(pkg => pkg.PackageName).Where(pkg => !excludedItems.Any(entry => pkg.IndexOf(entry, StringComparison.OrdinalIgnoreCase) >= 0)); + logWriter.Invoke($"Packages to remove: {packagesToRemove.Count()}"); + try { DismApi.Initialize(DismLogLevel.LogErrors); using DismSession session = DismApi.OpenOfflineSession(AppState.ScratchPath); + int idx = 0; foreach (string packageToRemove in packagesToRemove) { + curOpReporter.Invoke($"Removing package {packageToRemove}..."); + pbReporter.Invoke((int)(((double)idx / packagesToRemove.ToList().Count) * 100)); // we have this because the API throws an exception on removal error try { @@ -62,8 +71,10 @@ private void RemoveUnwantedPackages() } catch (Exception ex) { + logWriter.Invoke($"Package {packageToRemove} could not be removed: {ex.Message}"); DynaLog.logMessage($"ERROR: Failed to remove {packageToRemove}: {ex.Message}"); } + idx++; } } catch (Exception) @@ -72,6 +83,7 @@ private void RemoveUnwantedPackages() } finally { + pbReporter.Invoke(100); try { DismApi.Shutdown(); diff --git a/MicroWin/functions/dism/StoreAppRemover.cs b/MicroWin/functions/dism/StoreAppRemover.cs index f7b6826..ee0b0b2 100644 --- a/MicroWin/functions/dism/StoreAppRemover.cs +++ b/MicroWin/functions/dism/StoreAppRemover.cs @@ -33,33 +33,44 @@ public override List excludedItems { "CrossDevice" ]; - public override void RunTask() + public override void RunTask(Action pbReporter, Action curOpReporter, Action logWriter) { - RemoveStoreApps(); + RemoveStoreApps(pbReporter, curOpReporter, logWriter); } - private void RemoveStoreApps() + private void RemoveStoreApps(Action pbReporter, Action curOpReporter, Action logWriter) { + curOpReporter.Invoke("Getting image AppX packages..."); DismAppxPackageCollection allStoreApps = GetStoreAppsList(); if (allStoreApps is null) return; + logWriter.Invoke($"Amount of AppX packages in image: {allStoreApps.Count}"); + + curOpReporter.Invoke("Filtering image AppX packages..."); IEnumerable appsToRemove = allStoreApps.Select(appx => appx.PackageName).Where(appx => !excludedItems.Any(entry => appx.IndexOf(entry, StringComparison.OrdinalIgnoreCase) >= 0)); + logWriter.Invoke($"AppX packages to remove: {appsToRemove.Count()}"); + try { DismApi.Initialize(DismLogLevel.LogErrors); using DismSession session = DismApi.OpenOfflineSession(AppState.ScratchPath); + int idx = 0; foreach (string appToRemove in appsToRemove) { + curOpReporter.Invoke($"Removing AppX package {appToRemove}..."); + pbReporter.Invoke((int)(((double)idx / appsToRemove.ToList().Count) * 100)); try { DismApi.RemoveProvisionedAppxPackage(session, appToRemove); } catch (Exception ex) { + logWriter.Invoke($"AppX package {appToRemove} could not be removed: {ex.Message}"); DynaLog.logMessage($"ERROR: Failed to remove {appToRemove}: {ex.Message}"); } + idx++; } } catch (Exception) @@ -68,6 +79,7 @@ private void RemoveStoreApps() } finally { + pbReporter.Invoke(100); try { DismApi.Shutdown(); diff --git a/MicroWin/functions/dism/UnattendGenerator.cs b/MicroWin/functions/dism/UnattendGenerator.cs index 8dc0745..4b454bd 100755 --- a/MicroWin/functions/dism/UnattendGenerator.cs +++ b/MicroWin/functions/dism/UnattendGenerator.cs @@ -9,6 +9,8 @@ public class UnattendGenerator { public static void CreateUnattend(string destinationPath) { + // TODO Condition the specialize pass to filter out components that don't exist on Windows 10. + StringBuilder xml = new StringBuilder(); xml.AppendLine(""); xml.AppendLine(""); @@ -91,7 +93,26 @@ public static void CreateUnattend(string destinationPath) foreach (var user in AppState.UserAccounts) { xml.AppendLine(" "); - xml.AppendLine($" {user.Password}true</PlainText></Password>"); + xml.AppendLine($" <Password>"); + // Determine if we need to encode the password with base64. If we need to, we must append + // "Password" to the actual password; otherwise Setup/oobeSystem will fail. Base64 encoding is the only + // way Microsoft provides in order to hide sensitive info. + // https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/wsim/hide-sensitive-data-in-an-answer-file + if (AppState.EncodeWithB64) + { + string b64pass = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes($"{user.Password}Password")); + xml.AppendLine($" <Value>{b64pass}</Value>"); + xml.AppendLine($" <PlainText>false</PlainText>"); +#pragma warning disable IDE0059 + b64pass = ""; +#pragma warning restore IDE0059 + } + else + { + xml.AppendLine($" <Value>{user.Password}</Value>"); + xml.AppendLine($" <PlainText>true</PlainText>"); + } + xml.AppendLine($" </Password>"); xml.AppendLine($" <Name>{user.Name}</Name>"); xml.AppendLine($" <Group>{(user.Role == "Administrator" ? "Administrators" : "Users")}</Group>"); xml.AppendLine(" </LocalAccount>"); @@ -136,7 +157,19 @@ public static void CreateUnattend(string destinationPath) if (!Directory.Exists(destinationPath)) Directory.CreateDirectory(destinationPath); - File.WriteAllText(Path.Combine(destinationPath, "unattend.xml"), xml.ToString()); + string destXml = Path.Combine(destinationPath, "unattend.xml"); + + File.WriteAllText(destXml, xml.ToString()); + + if (AppState.CopyUnattendToFileSystem) + { + try + { + DynaLog.logMessage("Answer file will also be copied to the root of the system drive..."); + File.Copy(destXml, $"{Environment.GetEnvironmentVariable("SYSTEMDRIVE")}\\unattend.xml", true); + } + catch { } + } } catch (Exception ex) {