#190655 - 2008-11-19 03:01 PM
Change string in ini file without a index
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hello
I want to change a string value in a ini file . In the ini file there is no index like [server] or so . I want to change the string in the middle of a lang string example : I want to change the bold string to ICO=Mydomain
FAVOURITES MyFavouritesCompany10=20348721<element_attr>Purchase orders<element_attr>*FAVOURITES<element_attr>0<element_attr>functionStringToObject:<element_attr>functionToString:<element_attr>start<element_attr>PurchaseOrderEnquiry<element_attr> Navifunction.bmp<element_attr>Y<element_attr><element>*FAVO_OBJECTS<element_attr>Business objects<element_attr>*FAVOURITES<element_attr>100<element_attr>emptyStringToObject:<element_attr>undefinedObjectToString:<element_attr><element_attr><element_attr> Navifolder_blue.bmp<element_attr>Y<element_attr><element>*FAVO_FUNCTIONS<element_attr>Functions<element_attr>*FAVOURITES<element_attr>100<element_attr>emptyStringToObject:<element_attr>undefinedObjectToString:<element_attr><element_attr><element_attr> Navifolder_blue.bmp<element_attr>Y<element_attr><element> FAVOURITES MyFavouritesCompanyP2=*FAVO_OBJECTS<element_attr>Business objects<element_attr>*FAVOURITES<element_attr>100<element_attr>emptyStringToObject:<element_attr>undefinedObjectToString:<element_attr><element_attr><element_attr> Navifolder_blue.bmp<element_attr>Y<element_attr><element>*FAVO_FUNCTIONS<element_attr>Functions<element_attr>*FAVOURITES<element_attr>100<element_attr>emptyStringToObject:<element_attr>undefinedObjectToString:<element_attr><element_attr><element_attr> Navifolder_blue.bmp<element_attr>Y<element_attr><element> FILES_DEFAULT numberOfLocalRecordsForAdditionalFile=100 HOSTCONN AS/400CONNECTION ICOZZVD ICO=10.32.62.30<sep>ICO<sep>tcpip<sep>A600AP,A600DP,BE600DP,ZBE600DP<sep>N<sep>Y<sep>SAVELS<sep>987680 851943 987840 1024967 901550 592848 654656 <sep><sep>ICO600D<sep> HOSTCONN DefaultASWStartUpLibraries=A600AP
Could someone help me out how to change the value ICO .
Thanks
Edited by Lonkero (2008-11-20 06:23 PM)
|
|
Top
|
|
|
|
#190656 - 2008-11-19 03:50 PM
Re: Change string in ini file without a index
[Re: Shajoca]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Hmmm good one, here's one approach, assuming there is only 1 times "ICO=" in the ini file. Also it is untested so copy your ini file, I just wrote this out of the top of my head.
Dim $objFSO, $strIni, $objIni, $strTxt, $arrTxt, $strItm, $strItm2, $strIP
$objFSO = CreateObject("Scripting.FileSystemObject")
$strIni = "C:\someinifile.txt"
$strIP = "10.33.10.1"
$objIni = $objFSO.OpenTextFile($strIni, 1)
$strTxt = $objIni.ReadAll
$objIni.Close
$arrTxt = Split($strTxt,@CRLF)
For Each $strItm in $arrTxt
If Left($strItm,4) = "ICO="
$strItm2 = Split($strItm, "<")
? "IP: "+$strItm2[0]
$strItm2[0] = $strIP
$strItm = Join($strItm2, "<")
EndIf
Next
$strTxt = Join($arrTxt,@CRLF)
$objIni = $objFSO.OpenTextFile($strIni, 8, 1)
$objIni.Write($strTxt)
$objIni.Close
|
|
Top
|
|
|
|
#190657 - 2008-11-19 03:52 PM
Re: Change string in ini file without a index
[Re: Arend_]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
thanks , I gonne test right away .
|
|
Top
|
|
|
|
#190659 - 2008-11-19 04:13 PM
Re: Change string in ini file without a index
[Re: Jochen]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hi could you a Little clear out please the following variables Dim $objFSO, $strIni, $objIni, $strTxt, $arrTxt, $strItm, $strItm2, $strIP $objFSO = CreateObject("Scripting.FileSystemObject") $strIni = "C:\someinifile.txt" $strIP = "10.33.10.1" $objIni = $objFSO.OpenTextFile($strIni, 1) $strTxt = $objIni.ReadAll
I have the ini file that names app.ini this is located on the server but I but this also in a variable yet. could you clear the other variables like Ip and so
thx
|
|
Top
|
|
|
|
#190664 - 2008-11-19 05:06 PM
Re: Change string in ini file without a index
[Re: Shajoca]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Glenn: yeah that an approach, but I was assuming that was only the beginning of what he might change and also trying to show how you can go trough each line. But golfing wise it can be even shorter using then your suggestion 
Shajoca: I can't, those are the variables needed. Else try Glenn's suggestion.
|
|
Top
|
|
|
|
#190680 - 2008-11-20 08:35 AM
Re: Change string in ini file without a index
[Re: Arend_]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hi
but if I run the script the ini file will be not edited . Can i copy the script of you with no change in the variables or can you specify me what i need to change in the script of you. The only thing I could give you is the follwing Ini file = app.ini search string : ICO= must be changed to = ico=mydomain
Many Thanks
|
|
Top
|
|
|
|
#190681 - 2008-11-20 08:49 AM
Re: Change string in ini file without a index
[Re: Shajoca]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Ok, here's the "Glenn/apronk" special:
Dim $objFSO, $strIni, $objIni, $strTxt
$objFSO = CreateObject("Scripting.FileSystemObject")
$strIni = "C:\someinifile.txt"
$objIni = $objFSO.OpenTextFile($strIni, 8, 1)
$strTxt = $objIni.ReadAll
$strTxt = Join(Split($strTxt,"ICO=10.32.62.30"),"ICO=MyDomain")
$objIni.Write($strTxt)
$objIni.Close
|
|
Top
|
|
|
|
#190684 - 2008-11-20 09:11 AM
Re: Change string in ini file without a index
[Re: Arend_]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hi glenn is this correct ?
Dim $objFSO, $strIni, $objIni, $strTxt $objFSO = CreateObject("Scripting.FileSystemObject") $strIni = "C:\app.ini" $objIni = $objFSO.OpenTextFile($strIni, 8, 1) $strTxt = $objIni.ReadAll $strTxt = Join(Split($strTxt,"ICO=10.32.62.30"),"ICO=MyDomain") $objIni.Write($strTxt) $objIni.Close
I also insert in attach the kix script and the ini file that must be changed --> ico= to ico=mydomain thx
Attachments
Ibs.kix (174 downloads) Description:
Acssetup.ini (162 downloads) Description:
Edited by Shajoca (2008-11-20 09:34 AM) Edit Reason: attachments
|
|
Top
|
|
|
|
#190691 - 2008-11-20 02:06 PM
Re: Change string in ini file without a index
[Re: Jochen]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hi thanks for help but if I run this script , it will not change anything in the ini file .
Hopefully you could help me with this problem . I need to configure this till tis evening , tommorow there will be a little migration of this application to a other server . Otherwise I need to ga to each desktop for change ( 120 pcs) 
thx a lot
|
|
Top
|
|
|
|
#190693 - 2008-11-20 02:14 PM
Re: Change string in ini file without a index
[Re: Jochen]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
Hello
no the full string is %programfiles%\IBSAnalyser60\Users\Local\Acssetup.INI but I changed it for post on this forum . It's not posdsible to change someting that is in the middle of a string in the ini file .
Thx
|
|
Top
|
|
|
|
#190697 - 2008-11-20 04:02 PM
Re: Change string in ini file without a index
[Re: Mart]
|
Shajoca
Fresh Scripter
Registered: 2008-09-04
Posts: 17
|
THX a lot to you all . it works now.
|
|
Top
|
|
|
|
#190698 - 2008-11-20 04:18 PM
Re: Change string in ini file without a index
[Re: Jochen]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
But you could be if you wanted to. Just think how much more on fire you could be with all of those rockets!
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2009 anonymous users online.
|
|
|