<!-- Enable features --> <featureManager> <feature>webProfile-7.0</feature> <!-- <feature>localConnector-1.0</feature> --> </featureManager> <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" --> <httpEndpoint host="*" httpPort="7680" httpsPort="9443" id="defaultHttpEndpoint"/> <!-- Automatically expand WAR files and EAR files --> <applicationManager autoExpand="true"/> <applicationMonitor updateTrigger="mbean"/>
@echo off setlocal EnableExtensions DisableDelayedExpansion rem First check if the file to modify exists in directory of batch file. set "XmlFile=%~dp0\wlp\usr\server.xml" if not exist "%XmlFile%" goto EndBatch rem Define some environment variables which are needed later. set "NewPort=47682" set "LineNumber=" set "LineCount=0" set "TmpFile=%TEMP%\%~n0.tmp" rem Search for the line containing attribute httpPort and get its rem line number and the line itself loaded into environment variables. for /F "tokens=1* delims=:" %%I in ('%SystemRoot%\System32\findstr.exe /L /N /C:httpPort= "%XmlFile%" 2^>nul') do ( set "LineNumber=%%I" set "PortLine=%%J" ) rem If no line with attribute httpPort found, exit this batch file. if not defined LineNumber goto EndBatch rem Determine current number of attribute httpPort independent on where rem this attribute is specified in the XML line and replace this number rem in the line with the new port number as defined before. rem It is required for this type of number replace that the other port rem number for httpsPort is not the same number as current number for rem httpPort as in this case both numbers would be replaced by the new rem number. The attribute name and the equal sign cannot be included in rem the string substitution as used here. setlocal EnableDelayedExpansion set "PortNumber=!PortLine:*httpPort=!" for /F %%I in ("!PortNumber:~1!") do set "PortNumber=%%~I" set "PortLine=!PortLine:"%PortNumber%"="%NewPort%"!" endlocal & set "PortLine=%PortLine%" rem Make sure the temporary file used next does not already exist. del "%TmpFile%" 2>nul rem Copy all lines from XML file to a temporary file including empty rem lines with the exception of the line containing attribute httpPort rem which is copied to temporary file with the modified port number. for /F "tokens=1* delims=:" %%I in ('%SystemRoot%\System32\findstr.exe /R /N "^" "%XmlFile%" 2^>nul') do ( set "XmlLine=%%J" set /A LineCount+=1 setlocal EnableDelayedExpansion if not !LineCount! == %LineNumber% ( echo/!XmlLine!>>"%TmpFile%" ) else ( echo/!PortLine!>>"%TmpFile%" ) endlocal ) rem Overwrite original file with temporary file automatically deleted on success. move /Y "%TmpFile%" "%XmlFile%" >nul :EndBatch endlocal
From novice to tech pro — start learning today.