Jump to content

Config.ini update version


eJan
 Share

Recommended Posts

I'm tryng to replace .ini line with new one taken from FileGetVersion, but the way I have tryed doesn't work with asterisk. In my case .ini file have to be updated with version that I dont know, and the version in .ini file too.

I have tried with:

$ver = ("1.2.3") ; ??

$file = FileOpen("test.ini", 0)

Dim $contents

While 1

$line = FileReadLine($file)

If @error Then ExitLoop

If $line = "Version=*" Then $line = "Version=" & $ver ; * (asterisk not supported)

$contents = $contents & $line & @CRLF

WEnd

FileClose($file)

$file = FileOpen("test.ini", 2)

FileWrite($file, $contents)

.ini (in my case is line 39):

language_file=

Version=1.2.3

RunCount=15

Link to comment
Share on other sites

Line 8 doesn't work, use

If StringInStr ( $line, "Version=") then

Has the file sections like [General] or [Program] you should use

IniRead ( "filename", "section", "key", "default" ) 
IniWrite ( "filename", "section", "key", "value" )
Link to comment
Share on other sites

Thanks Westi, it works great!

IniRead ( "filename", "section", "key", "default" )

IniWrite ( "filename", "section", "key", "value" )

Now it looks like:

Func _IniWrite()

$regpath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Maxthon", "UninstallString")

$string = StringLeft($regpath, StringInStr($regpath, '\', 0, -1) - 1)

$exe = $string & "\Maxthon.exe"

$file = FileGetVersion($exe)

$exever = StringLeft($file, StringInStr($file, '.', 0, -1) - 1)

IniWrite($ini1, "Settings", "Version", $exever)

EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...