58 lines
2.2 KiB
Batchfile
58 lines
2.2 KiB
Batchfile
@echo off
|
|
REM Final Unlock Script - Multiple Methods
|
|
REM Run as Administrator
|
|
|
|
echo ========================================
|
|
echo FINAL HANDLERS UNLOCK
|
|
echo ========================================
|
|
echo.
|
|
|
|
cd /d "%~dp0"
|
|
|
|
REM Check if running as Administrator
|
|
net session >nul 2>&1
|
|
if %errorLevel% neq 0 (
|
|
echo [ERROR] Run as Administrator!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo Trying Method 1: PowerShell Set-WebConfigurationProperty...
|
|
powershell -Command "$ErrorActionPreference = 'Continue'; Import-Module WebAdministration; try { Set-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.webServer/handlers' -Name 'overrideMode' -Value 'Allow'; Write-Host '[OK] Method 1: Handlers unlocked' } catch { Write-Host '[FAILED] Method 1 failed:' $_.Exception.Message }"
|
|
|
|
echo.
|
|
echo Trying Method 2: Direct XML Edit...
|
|
powershell -Command "$ErrorActionPreference = 'Continue'; $configPath = 'C:\Windows\System32\inetsrv\config\applicationHost.config'; if (Test-Path $configPath) { $content = Get-Content $configPath -Raw; if ($content -match '<section name=\"handlers\" overrideModeDefault=\"Deny\"') { $content = $content -replace '<section name=\"handlers\" overrideModeDefault=\"Deny\"', '<section name=\"handlers\" overrideModeDefault=\"Allow\"'; Set-Content $configPath $content -NoNewline; Write-Host '[OK] Method 2: applicationHost.config updated' } else { Write-Host '[INFO] Method 2: Already set to Allow or different format' } } else { Write-Host '[FAILED] Method 2: Config file not found' }"
|
|
|
|
echo.
|
|
echo Trying Method 3: Using appcmd...
|
|
if exist "C:\Windows\System32\inetsrv\appcmd.exe" (
|
|
C:\Windows\System32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
|
|
if %errorLevel% equ 0 (
|
|
echo [OK] Method 3: appcmd unlock successful
|
|
) else (
|
|
echo [FAILED] Method 3: appcmd unlock failed
|
|
)
|
|
) else (
|
|
echo [SKIP] Method 3: appcmd not found
|
|
)
|
|
|
|
echo.
|
|
echo Restarting IIS...
|
|
iisreset /noforce
|
|
|
|
echo.
|
|
echo ========================================
|
|
echo UNLOCK ATTEMPTED
|
|
echo ========================================
|
|
echo.
|
|
echo If still error, unlock manually:
|
|
echo 1. IIS Manager
|
|
echo 2. Server (root) ^> Feature Delegation
|
|
echo 3. Handler Mappings ^> Read/Write
|
|
echo.
|
|
echo Then test: http://localhost
|
|
echo.
|
|
pause
|
|
|