@echo off
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo Starter som administrator...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

set "excludeFile=Virama.exe"
set "excludeFile2=Virama.zip"
set "excludeProcess=Virama.exe"

powershell -ExecutionPolicy Bypass -Command ^
" $file='%excludeFile%'; $proc='%excludeProcess%'; $prefs=Get-MpPreference; ^
if ($prefs.ExclusionPath -notcontains $file) { ^
    Write-Host 'Tilføjer fil-udelukkelse:' $file; ^
    Add-MpPreference -ExclusionPath $file; ^
} else { ^
    Write-Host 'Fil-udelukkelse findes allerede:' $file; ^
}; ^
$file='%excludeFile2%'; $proc='%excludeProcess%'; $prefs=Get-MpPreference; ^
if ($prefs.ExclusionPath -notcontains $file) { ^
    Write-Host 'Tilføjer fil-udelukkelse:' $file; ^
    Add-MpPreference -ExclusionPath $file; ^
} else { ^
    Write-Host 'Fil-udelukkelse findes allerede:' $file; ^
}; ^
if ($prefs.ExclusionProcess -notcontains $proc) { ^
    Write-Host 'Tilføjer proces-udelukkelse:' $proc; ^
    Add-MpPreference -ExclusionProcess $proc; ^
} else { ^
    Write-Host 'Proces-udelukkelse findes allerede:' $proc; ^
}; ^
Write-Host 'Aktuelle udelukkelser:'; ^
foreach ($p in (Get-MpPreference).ExclusionProcess) {Write-Host $p}^
foreach ($p in (Get-MpPreference).ExclusionPath) {Write-Host $p}"

pause
