Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MicroWin/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class AppState
public static DriverExportMode DriverExportMode { get; set; } = DriverExportMode.NoExport;
public static bool UseUEFICA23Bins { get; set; } = true;
public static string? SaveISO { get; set; }
public static string? WinUtilConfigPath { get; set; }

public static string Version => "v2.0";
}
Expand Down
43 changes: 43 additions & 0 deletions MicroWin/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion MicroWin/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,18 @@ private void UEFICA23CB_CheckedChanged(object sender, EventArgs e)
AppState.UseUEFICA23Bins = UEFICA23CB.Checked;
}

private void winutilConfigTextBox_TextChanged(object sender, EventArgs e)
{
AppState.WinUtilConfigPath = winutilConfigTextBox.Text;
}

private void winutilConfigBrowseBtn_Click(object sender, EventArgs e)
{
if (winutilConfigDialog.ShowDialog() == DialogResult.OK)
{
winutilConfigTextBox.Text = winutilConfigDialog.FileName;
}
}

private void UpdateCurrentStatus(string text, bool resetBar = true)
{
Expand Down Expand Up @@ -662,7 +674,21 @@ await Task.Run(async () =>
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);
string firstStartupPath = Path.Combine(AppState.ScratchPath, "Windows", "FirstStartup.ps1");
File.WriteAllBytes(firstStartupPath, data);

if (!string.IsNullOrWhiteSpace(AppState.WinUtilConfigPath) && File.Exists(AppState.WinUtilConfigPath))
{
File.Copy(AppState.WinUtilConfigPath, Path.Combine(AppState.ScratchPath, "winutil-config.json"), true);
WriteLogMessage("WinUtil configuration file copied to image.");

string scriptToAppend = "\n\nif (Test-Path -Path \"$env:HOMEDRIVE\\winutil-config.json\")\n" +
"{\n" +
" Write-Host \"Configuration file detected. Applying...\"\n" +
" iex \"& { $(irm christitus.com/win) } -Config `\"$env:HOMEDRIVE\\winutil-config.json`\"\"\n" +
"}\n";
File.AppendAllText(firstStartupPath, scriptToAppend);
}
}
catch { }
}
Expand Down