How to Change an IIS Setting with AppCmd
Current IIS uses applicationHost.config and distributed web.config files. The old EnableEditWhileRunning switch in MetaBase.xml belongs to IIS 6 and is not the way to manage IIS 10.
Bind the change to one application
In an elevated Windows PowerShell console on a test IIS server, list the actual application paths:
$appcmd = Join-Path $env:windir 'System32\inetsrv\appcmd.exe'
& $appcmd list app
Choose a real test application. The following example uses Default Web Site/Demo and turns directory browsing off only at that configuration path:
$appPath = 'Default Web Site/Demo'
& $appcmd list config $appPath /section:system.webServer/directoryBrowse
if ($LASTEXITCODE -ne 0) { throw 'Could not read the application configuration.' }
& $appcmd set config $appPath /section:system.webServer/directoryBrowse /enabled:false /commit:apphost
if ($LASTEXITCODE -ne 0) { throw 'Configuration was not saved.' }
& $appcmd list config $appPath /section:system.webServer/directoryBrowse
The readback should show enabled="false". /commit:apphost selects where the configuration is written. The application path still limits where the setting applies. Keep the original value and whether it was inherited before changing it.
Verify behavior, not just the command
Request a directory that has neither a default document nor an application route. IIS should no longer produce a directory listing. A normal page request is not a useful test of directory-browsing behavior.
Supported configuration changes are picked up by IIS. There is no blanket requirement to run iisreset. Some settings still cause application or worker-process lifecycle changes. Check the specific setting and the application's tolerance for a restart rather than promising every edit is interruption-free.
A locked section is a policy boundary. Inspect the lock and intended owner instead of unlocking the entire server. To roll back, restore the recorded explicit value or remove the specific override to recover inheritance. Do not restore an old whole-server backup over unrelated changes.
References


Author: Herman Schoenfeld