22 lines
950 B
PowerShell
22 lines
950 B
PowerShell
# DisableVHDExpand.ps1
|
|
# Wymaga uruchomienia z uprawnieniami Administratora
|
|
#Requires -RunAsAdministrator
|
|
|
|
Write-Host "Konfiguracja dysków VHD..." -ForegroundColor Cyan
|
|
|
|
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\FsDepends\Parameters"
|
|
|
|
# Upewniamy się, że klucz Parameters istnieje (domyślnie powinien, ale lepiej sprawdzić)
|
|
if (-not (Test-Path $regPath)) {
|
|
New-Item -Path $regPath -Force | Out-Null
|
|
}
|
|
|
|
try {
|
|
# Wartość 4 oznacza wyłączenie rozszerzania VHD przy rozruchu
|
|
Set-ItemProperty -Path $regPath -Name "VirtualDiskExpandOnMount" -Value 4 -Type DWord
|
|
|
|
Write-Host "[SUKCES] Ustawiono VirtualDiskExpandOnMount na wartość 4." -ForegroundColor Green
|
|
Write-Host " Dynamiczne dyski VHD nie będą już sztucznie puchnąć przy starcie." -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "[BŁĄD] Nie udało się zmodyfikować rejestru. Szczegóły: $_" -ForegroundColor Red
|
|
} |