Fix the format failure when install Ventoy.

This commit is contained in:
longpanda
2022-12-16 17:03:05 +08:00
parent 27eda4d1e7
commit c76ece4b74
21 changed files with 829 additions and 104 deletions

View File

@@ -29,15 +29,9 @@
STATIC BOOL IsPowershellExist(void)
{
BOOL ret;
BOOL ret;
if (!IsWindows8OrGreater())
{
Log("This is before Windows8 powershell disk not supported.");
return FALSE;
}
ret = IsFileExist("C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe");
ret = IsFileExist("%s\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", DISK_GetWindowsDir());
if (!ret)
{
Log("powershell.exe not exist");
@@ -261,6 +255,7 @@ BOOL PSHELL_FormatVolume(char DriveLetter, int fs, DWORD ClusterSize)
BOOL ret;
const char* fsname = NULL;
CHAR CmdBuf[512];
CHAR FsName[128];
fsname = GetVentoyFsFmtNameByTypeA(fs);
@@ -279,5 +274,26 @@ BOOL PSHELL_FormatVolume(char DriveLetter, int fs, DWORD ClusterSize)
ret = PSHELL_CommProc(CmdBuf);
Log("PSHELL_FormatVolume %C: ret:%d (%s)", DriveLetter, ret, ret ? "SUCCESS" : "FAIL");
return ret;
if (!ret)
{
return FALSE;
}
sprintf_s(CmdBuf, sizeof(CmdBuf), "%C:\\", DriveLetter);
GetVolumeInformationA(CmdBuf, NULL, 0, NULL, NULL, NULL, FsName, sizeof(FsName));
VentoyStringToUpper(FsName);
Log("New fs name after run PSHELL:<%s>", FsName);
if (strcmp(FsName, fsname) == 0)
{
Log("PSHELL_FormatVolume <%C:> SUCCESS", DriveLetter);
return TRUE;
}
else
{
Log("PSHELL_FormatVolume <%C:> FAILED", DriveLetter);
return FALSE;
}
}