此脚本会将当前重命名deferredreportsdaemon.ini
为deferredreportsdaemon.ini.old
并创建一个新的deferredreportsdaemon.ini
.
注意:这可能不是最好、最有效的方法,但它似乎对我有用。此外,您将需要添加更多错误检查,因为我在这里不做任何事情......
@echo off
set /P DBNAME="Please enter an Application Database Name: "
set INI=deferredreportsdaemon.ini
set OLD=%INI%.old
copy /Y %INI% %OLD%
del %INI%
FOR /F "delims=\= tokens=1,2" %%K IN (%OLD%) DO (
IF "%%K" NEQ "ApplicationDatabaseServer" echo %%K=%%L >>%INI%
)
echo ApplicationDatabaseServer=%DBNAME% >>%INI%
初始ini文件内容:
ApplicationDatabaseClass=com.systems.pool.MySQLConnectionManager
ApplicationDatabaseUser=administrator
ApplicationDatabasePassword=test
ApplicationDatabaseName=envdata
ApplicationDatabaseServer=eis-mysql0:3308
运行脚本并输入后my_database_name
:
ApplicationDatabaseClass=com.systems.pool.MySQLConnectionManager
ApplicationDatabaseUser=administrator
ApplicationDatabasePassword=test
ApplicationDatabaseServer=eis-mysql0:3308
ApplicationDatabaseName=my_database_name