@echo off @echo ................................................. @echo Open AHADMIN remoting through a specific endpoint @echo ................................................. @set appkey=HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{9fa5c497-f46d-447f-8011-05d03d7d7ddc} IF "%~1"=="" GOTO View IF "%~1"=="0" GOTO Delete @echo Setting AHADMIN TCP port to %1 @REG ADD %APPKEY% /v EndPoints /d "ncacn_ip_tcp,0,%1" /t REG_MULTI_SZ /f @echo Opening firewall: TCP 135/DCOM port mapper netsh advfirewall firewall delete rule name="RPC Mapper" netsh advfirewall firewall add rule name="RPC Mapper" dir=in action=allow profile=private remoteip=localsubnet protocol=tcp localport=135 service=RpcSs @echo Opening firewall: TCP %1/fixed AHADMIN endpoint netsh advfirewall firewall delete rule name="AHADMIN Fixed Endpoint" netsh advfirewall firewall add rule name="AHADMIN Fixed Endpoint" dir=in action=allow profile=private remoteip=localsubnet protocol=tcp localport=%1 program=%windir%\system32\dllhost.exe GOTO End :View @echo The ahadmin endpoint is: @REG QUERY %APPKEY% /v EndPoints @IF ERRORLEVEL 1 @echo EndPoints not set - using default (dynamically allocated by DCOM). GOTO End :Delete @echo Removing fixed ahadmin endpoint @REG DELETE %APPKEY% /v EndPoints /f @echo Removing firewall rules netsh advfirewall firewall delete rule name="RPC Mapper" netsh advfirewall firewall delete rule name="AHADMIN Fixed Endpoint" GOTO End :End