Skip to content

Instantly share code, notes, and snippets.

@dyavuz
Last active April 8, 2024 20:29
Show Gist options
  • Save dyavuz/e58e839464f1e66206dd318229a29224 to your computer and use it in GitHub Desktop.
Save dyavuz/e58e839464f1e66206dd318229a29224 to your computer and use it in GitHub Desktop.
# https://stackoverflow.com/a/59343705
$env:PATH = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
[AppDomain]::CurrentDomain.GetAssemblies() | ForEach-Object {
$path = $_.Location
if ($path) {
$name = Split-Path $path -Leaf
Write-Host -ForegroundColor Yellow "`r`nRunning ngen.exe on '$name'"
ngen.exe install $path /nologo
}
}
$VcRedists = [ordered]@{
"2005" = "/Q"
"2008" = "/q"
"2010" = "/q /norestart"
"2012" = "/install /quiet /norestart"
"2013" = "/install /quiet /norestart"
"2015+" = "/install /quiet /norestart"
}
foreach ($VcRedistYear in $VcRedists.Keys) {
foreach ($Arch in "x86", "x64") {
& winget install --accept-source-agreements --accept-package-agreements --exact "Microsoft.VCRedist.${VcRedistYear}.${Arch}" --override $VcRedists.$VcRedistYear
}
}
# Disable Windows Defender within Safe Boot
$WdServices = $(
"MDCoreSvc"
"SecurityHealthService"
"WdNisSvc"
"WinDefend"
"wscsvc"
)
foreach ($WdService in $WdServices) {
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\$WdService" -Name "Start" -PropertyType DWord -Value 4 -Force | Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment