Jump to content
Sign in to follow this  

Remove Part of Value in an ini

Recommended Posts


I am trying to remove part of a value of a multi-valued ini key.

I tried IniDelete, but that deletes the entire key including any values.

My current situation is that I have an ini value like:


Key=1, 2, 3

I want to edit it to look like this:


Key=2, 3

Thank you for the help.

Share this post

Link to post
Share on other sites

IniWriteSection("test.ini", "Section", "2,3")

Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post

Link to post
Share on other sites

Sorry, I should of clarified.

I don't know what values 2,3 are.

This modification is for notes.ini for Lotus Notes. We are removing one addin to lotus notes, but we do not want delete the whole line because it disables all the addins.

Different users use different addins with Lotus Notes, so I can't delete the whole line and write a generic one in its place.

Share this post

Link to post
Share on other sites

I am interested in how to do this also, let me know if you figure it out.

Share this post

Link to post
Share on other sites

See if this (AutoIt3 code) will do the trick:

;~ $keyname = "DisabledPorts"

;~ $remove = "com5"

$keyname = "TCPIP_TcpConnectTimeout"

$remove = "0"

;~ $keyname = "EmptyTrash"

;~ $remove = "0"

$inifile = "c:\lotus\notes\notes.ini"

$sectionname = "Notes"

$s = IniRead($inifile, $sectionname, $keyname, "")

If StringLen($s) = 0 Then

ConsoleWrite("Key not found?" & @CRLF)



ConsoleWrite("$s= " & $s & @CRLF)

$rc = StringInStr($s, $remove)

ConsoleWrite("$rc= " & $rc & @CRLF)

$out = ""

If $rc > 0 Then

$ss = StringSplit($s, ",")

If $ss[0] > 0 Then

; $out = $ss[1]

For $i = 1 To $ss[0]

$sss = $ss[$i]

ConsoleWrite("$ss[" & $i & "]=" & $sss & @CRLF)

If StringCompare($remove, $sss) Then

ConsoleWrite("Keep " & $sss & @CRLF)

If StringLen($out) > 0 Then

$out = $out & ","

ConsoleWrite("$out = " & $out & @CRLF)


$out = $out & $sss


ConsoleWrite("Drop " & $sss & @CRLF)



ConsoleWrite("String to write is: " & $out & @CRLF)


ConsoleWrite("No multi-values found?" & @CRLF)



ConsoleWrite("String to remove not found?" & @CRLF)


As you can see at the top of the code, I tried several keyvalues, it seems to handle multi, double and single values.

Good Luck

P.S. All my nice formatting got stripped, but I have no idea what I'm doing anyway, so I'm not surprised!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.