# Центровка описаний в BCD: слева+справа добиваем до 33 символов (U+00A0). $store = 'F:\efi\Paravis\Boot\bcd\bcd' $log = 'C:\PF\bcd-center2.log' $gfm = '{212da646-f065-474f-a688-d0ebfefd1573}' $krd = '{de2ba8ef-1a63-40cd-aeec-56a8efcb0886}' $nbsp = [string][char]0x00A0 $out = @() if (Get-Process -Name vmware-vmx -ErrorAction SilentlyContinue) { 'VMWARE RUNNING' | Out-File -FilePath $log -Encoding utf8 exit 1 } function Run([string[]]$argv) { $r = & bcdedit @argv 2>&1 $script:out += ('> bcdedit ' + ($argv[0..4] -join ' ') + ' ...') $script:out += (' exit=' + $LASTEXITCODE) } $krdText = ($nbsp * 4) + 'Kaspersky Rescue Disk 24' + ($nbsp * 5) # 4 + 24 + 5 = 33 $vtText = ($nbsp * 7) + 'Ventoy (ISO образы)' + ($nbsp * 7) # 7 + 19 + 7 = 33 Run @('/store', $store, '/set', $krd, 'description', $krdText) Run @('/store', $store, '/set', $gfm, 'description', $vtText) # контроль $b = [IO.File]::ReadAllBytes($store) function Find-Utf16([byte[]]$hay, [string]$s) { $needle = [Text.Encoding]::Unicode.GetBytes($s) for ($i = 0; $i -le $hay.Length - $needle.Length; $i++) { $ok = $true for ($j = 0; $j -lt $needle.Length; $j++) { if ($hay[$i+$j] -ne $needle[$j]) { $ok = $false; break } } if ($ok) { return $i } } return -1 } foreach ($t in 'Kaspersky Rescue Disk 24','Ventoy (ISO образы)') { $p = Find-Utf16 $b $t $lead = 0 while ($p - 2 - $lead*2 -ge 0 -and $b[$p-2-$lead*2] -eq 0xA0 -and $b[$p-1-$lead*2] -eq 0x00) { $lead++ } $end = $p + [Text.Encoding]::Unicode.GetByteCount($t) $trail = 0 while ($end + $trail*2 + 1 -lt $b.Length -and $b[$end+$trail*2] -eq 0xA0 -and $b[$end+$trail*2+1] -eq 0x00) { $trail++ } $out += (' {0}: слева {1}, справа {2}, всего {3}' -f $t, $lead, $trail, ($lead + $t.Length + $trail)) } $out | Out-File -FilePath $log -Encoding utf8