Change certain line in ini file????

February 26, 2009 at 05:04:47
Specs: Windows XP
Hello to everybody,

Here is the ini file that shuld be changed with batch (*.bat)

[General]
ClientCountry = Yu
ClientName=AGB SR
CountryCode = 19

[INITIAL_SETTINGS]
ManualDownload =1
OverwriteWithNoPrompt =1
ShowLastDaysComboBoxIndex =5
FtpTimeout = 20

[PROXY]
;'0' - don't use proxy server, '1' - use proxy server
UseProxy=0
Host=
Port =0

[DATA_SERVERS]
ServerHost1=192.168.1.1
Username1 =xxx
Password1 =xxx
ShowLastDaysRelativeToCurrentDate1 =0
Protocol1 =http
DataTypes1=RDS,EVS,RSP,SPOMDB,PDD,MRG


[RDS]
Description =RDS
ServerDatabaseFilePath=/agbmk/RDS/RDS_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\rds.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\rds\

[EVS]
Description =EVS
ServerDatabaseFilePath=/agbmk/EVS/EVS_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\evs.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\evs\

[RSP]
Description =RSP
ServerDatabaseFilePath=/agbmk/RSP/RSP_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\rsp.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\rsp\

[SPOMDB]
Description =SPOMDB
ServerDatabaseFilePath=/agbmk/SPOMDB/SPOMDB_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\spomdb.db
DestinationDirectoryPath=c:\arianna\environments\mac\db\


[PDD]
Description =PDD
ServerDatabaseFilePath=/agbmk/PDD/PDD_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\pdd.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\pdd\

[MRG]
Description =MRG
ServerDatabaseFilePath=/agbmk/MRG/MRG_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\mrg.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\mrg\


And after the bach file here is what shuld look after change:

[General]
ClientCountry = Yu
ClientName=AGB SR
CountryCode = 19

[INITIAL_SETTINGS]
ManualDownload =1
OverwriteWithNoPrompt =1
ShowLastDaysComboBoxIndex =5
FtpTimeout = 20

[PROXY]
;'0' - don't use proxy server, '1' - use proxy server
UseProxy=0
Host=
Port =0

[DATA_SERVERS]
ServerHost1=192.168.1.30
Username1 =xxx
Password1 =xxx
ShowLastDaysRelativeToCurrentDate1 =0
Protocol1 =http
DataTypes1=RDS,EVS,RSP,SPOMDB,PDD,MRG


[RDS]
Description =RDS
ServerDatabaseFilePath=/agbmk/RDS/RDS_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\rds.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\rds\

[EVS]
Description =EVS
ServerDatabaseFilePath=/agbmk/EVS/EVS_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\evs.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\evs\

[RSP]
Description =RSP
ServerDatabaseFilePath=/agbmk/RSP/RSP_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\rsp.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\rsp\

[SPOMDB]
Description =SPOMDB
ServerDatabaseFilePath=/agbmk/SPOMDB/SPOMDB_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\spomdb.db
DestinationDirectoryPath=c:\arianna\environments\mac\db\


[PDD]
Description =PDD
ServerDatabaseFilePath=/agbmk/PDD/PDD_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\pdd.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\pdd\

[MRG]
Description =MRG
ServerDatabaseFilePath=/agbmk/MRG/MRG_http.map
LocalDatabaseFilePath=c:\agb\agbws\smartupdate\db\mrg.db
DestinationDirectoryPath=c:\arianna\environments\mac\data\mrg\

The only thing should be changed is the (Serverhosts1 under Data Servers) ip adresess from 192.168.1.1 to 192.168.1.30.

Can someone help me to make batch file (*.bat) to make this change. I need to make this change to 50 computers ,so I need this batch file. All users are administrators.

Thanks in Advance to ALL who will try to help me.

Sincierly
Goce Pejcinovski


See More: Change certain line in ini file????

Report •


#1
February 26, 2009 at 07:51:41

@echo off > new.ini & setLocal EnableDelayedExpansion

for /f "tokens=1* delims= " %%a in ('find /v /n "" ^< my.ini') do (
if not %%b'==' (
set str=%%b
set str=!str:192.168.1.1=192.168.1.30!
echo !str! >> new.ini
) else (
echo. >> new.ini
)
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
February 26, 2009 at 08:03:10
In the following batch replace "Path_Of_INI_File" with the folder location where the INI file is stored and "Your_INI_File" with the ini file name (assumed its extension is .ini).

The modified .ini has no blank lines as they are missed while the replacement occurs.

@echo off & setlocal EnableDelayedExpansion
pushd "Path_Of_INI_file"
for /F "delims=" %%j in (Your_INI_File.ini) do (
  set line=%%j
  set line=!line:192.168.1.1=192.168.1.30!
  echo.!line!>> Your_INI_file.new
)
del Your_INI_File.ini
ren *.new *.ini
popd
:: End_Of_Batch


Report •

Related Solutions


Ask Question