Skip to content

Commit 0652c61

Browse files
system_debug, tools: added exception handling for init errors (oneapi-src#301)
1 parent a3397dd commit 0652c61

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Tools/SystemDebug/efi_application/tools/make_boot_media.ps1

+10-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,19 @@ if ($Results.PartitionStyle -eq "MBR") {
5757
Write-Error "Please convert disk to GPT first"
5858
exit
5959
}
60+
Reset-PhysicalDisk -FriendlyName $Results.FriendlyName
6061

61-
Initialize-Disk -FriendlyName $Results.FriendlyName -PartitionStyle GPT -PassThru |
62-
New-Partition -UseMaximumSize -GptType "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}" -AssignDriveLetter |
62+
try {
63+
Initialize-Disk -FriendlyName $Results.FriendlyName -PartitionStyle GPT -PassThru
64+
}
65+
catch {
66+
Write-Output "Disk cannot be initialised"
67+
}
68+
69+
$Drive = New-Partition -DiskNumber $Results.DiskNumber -UseMaximumSize -GptType "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}" -AssignDriveLetter |
6370
Format-Volume -NewFileSystemLabel "EFI" -FileSystem FAT32 -Force
6471

65-
$USBDrive = ($Results.DriveLetter + ':\')
72+
$USBDrive = ($Drive.DriveLetter + ':\')
6673

6774
$RelativePath = "\\EFI\\Boot"
6875
$DestPath = $USBDrive + $RelativePath

0 commit comments

Comments
 (0)