Upload files to "/"
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# OptimizeVHD.ps1
|
||||
# Wymaga uruchomienia z uprawnieniami Administratora
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
Write-Host "Optymalizacja systemu pod obraz VHD / Snapshoty..." -ForegroundColor Cyan
|
||||
|
||||
# 1. Wyłączenie Hibernacji i Szybkiego Uruchamiania (Fast Startup)
|
||||
# To usunie plik hiberfil.sys, który potrafi zajmować tyle GB, ile masz RAMu
|
||||
Write-Host "[1/2] Wyłączanie hibernacji (hiberfil.sys)..." -NoNewline
|
||||
try {
|
||||
# Najczystsza metoda zalecana przez Microsoft to powercfg, która sama modyfikuje rejestr
|
||||
# w kluczu HKLM\System\CurrentControlSet\Control\Power (wartość HibernateEnabled)
|
||||
Start-Process -FilePath "powercfg.exe" -ArgumentList "/hibernate off" -Wait -NoNewWindow
|
||||
Write-Host " GOTOWE" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " BŁĄD" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# 2. Ustawienie stałego rozmiaru pliku stronicowania (Pagefile)
|
||||
# Zapobiega nagłemu puchnięciu VHD przy braku pamięci RAM
|
||||
Write-Host "[2/2] Ustawianie stałego rozmiaru pliku stronicowania (2048 MB)..." -NoNewline
|
||||
try {
|
||||
# Wyłączenie automatycznego zarządzania plikiem stronicowania w rejestrze
|
||||
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
|
||||
Set-ItemProperty -Path $regPath -Name "AutomaticManagedPagefile" -Value 0 -Type DWord
|
||||
|
||||
# Ustawienie stałego rozmiaru (np. Min 2048 MB, Max 2048 MB)
|
||||
# Jeśli chcesz mniejszy lub większy, zmień wartości "2048 2048" poniżej
|
||||
Set-ItemProperty -Path $regPath -Name "PagingFiles" -Value "C:\pagefile.sys 2048 2048" -Type MultiString
|
||||
|
||||
Write-Host " GOTOWE" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " BŁĄD" -ForegroundColor Red
|
||||
Write-Host " Szczegóły: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "==========================================" -ForegroundColor Cyan
|
||||
Write-Host "UWAGA: Zmiany w pliku stronicowania będą aktywne po ponownym uruchomieniu komputera." -ForegroundColor Yellow
|
||||
Reference in New Issue
Block a user