@echo off setlocal enabledelayedexpansion set "regPath=HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0\xxxx_Tomcat7\Parameters\Java"
set "append=\0-XX:+UseConcMarkSweepGC\0-XX:+UseParNewGC\0-XX:NewRatio=1\0-XX:+PrintGCDetails\0-XX:+PrintGCDateStamps\0-XX:+HeapDumpOnOutOfMemoryError"
for /f "delims=" %%A in ('reg query "%regPath%" /v Options') do ( set "line=%%A" ) echo "注册表原值:"%line% echo.
rem 截取字符串 set "substring=!line:*REG_MULTI_SZ =!" echo "截取Data:"%substring% echo.
rem 不包含UseConcMarkSweepGC,则拼接新参数 if not "!substring!"=="!substring:UseConcMarkSweepGC=!" ( echo 已经包含UseConcMarkSweepGC,本次不操作 ) else ( set "result=!substring!%append%" echo "新Data:"!result! reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0\xxxx_Tomcat7\Parameters\Java" /v Options /t REG_MULTI_SZ /d "!result!" /f echo "已添加UseConcMarkSweepGC参数" ) pause
|