From 320e154457d108bdfb7a44d23d4d30b7ec1803aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20Kentt=C3=A4?= Date: Sat, 22 Feb 2025 14:02:02 +0200 Subject: [PATCH] Check for missing mountvol /S --- src/Esp.cs | 19 ++++++++++++++++++- src/Setup.cs | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Esp.cs b/src/Esp.cs index f71e1e9..cb7b200 100644 --- a/src/Esp.cs +++ b/src/Esp.cs @@ -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) { diff --git a/src/Setup.cs b/src/Setup.cs index 6a5eba1..29124e8 100644 --- a/src/Setup.cs +++ b/src/Setup.cs @@ -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}");