Check for missing mountvol /S

This commit is contained in:
Lauri Kenttä
2025-02-22 14:02:02 +02:00
parent 785307c0e2
commit 320e154457
2 changed files with 21 additions and 1 deletions

View File

@@ -19,6 +19,19 @@ public sealed class Esp {
}
}
/** Output of mountvol. */
private static string MountvolOutput;
/** Does MountvolOutput contain /S? */
public static bool MountvolESPNotSupported {
get {
if (MountvolOutput == null) {
MountvolOutput = Setup.Execute("mountvol", "", false);
}
return MountvolOutput.Contains(" /S") == false;
}
}
/**
* Constructor: do nothing.
*/
@@ -74,8 +87,9 @@ public sealed class Esp {
Setup.Log("Esp.Find()");
try {
// Match "The EFI System Partition is mounted at E:\" with some language support.
MountvolOutput = Setup.Execute("mountvol", "", false);
var re = new Regex(" EFI[^\n]*(?:\n[ \t]*)?([A-Z]:\\\\)");
var m = re.Match(Setup.Execute("mountvol", "", false));
var m = re.Match(MountvolOutput);
if (m.Success && TryPath(m.Groups[1].Captures[0].Value)) {
return true;
}
@@ -102,6 +116,9 @@ public sealed class Esp {
if (MountInstance != null) {
return true;
}
if (MountvolESPNotSupported) {
return false;
}
for (char c = 'A'; c <= 'Z'; ++c) {
Setup.Log($"Esp.Mount: {c}");
if (Setup.Execute("mountvol", c + ": /S", true) != null) {

View File

@@ -300,6 +300,9 @@ public class Setup {
}
if (Esp.Location == null && !Esp.Find() && !Esp.Mount() && !Batch) {
WriteLine("EFI System Partition was not found.");
if (Esp.MountvolESPNotSupported) {
WriteLine("Your computer doesn't support mountvol /S. You have to mount ESP manually.");
}
WriteLine("Press enter to exit, or give ESP path here: ");
string s = Console.ReadLine();
Log($"User input: {s}");