Old 4th September 2011, 15:50   #1
Rajada
Junior Member
 
Join Date: Mar 2011
Posts: 14
Ini edit not being observed by installer

I have an installer that edits the ini file of a particular application. The installer basically changes the value of an integer to a non-zero value (the exact number depends on the situation). If the ini line has a value of zero, the exe carries out function A (just using placeholder names) and if the value is not zero it carries out function B.

If I edit the number in the ini with a text editor everything runs fine afterwards. If I let the installer edit the value, then exit the installer and run the exe everything still runs fine. The problem comes in if I have the exe listed as the program to run after installation is complete. If I run the exe using the checkbox at the end of the installer (close installer and run exe), the exe acts as if the ini value is 0, no matter what it really is set to.

Is there some ini save function I need to call to get this to behave the correct way?
Rajada is offline   Reply With Quote
Old 4th September 2011, 17:46   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
First of all, verify that the value is correctly set to non-zero, before you click Finish on the finish page.

Second, what OS is this? Admin or user? What directory is the ini file in?
MSG is offline   Reply With Quote
Old 4th September 2011, 18:33   #3
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
Did you use the FlushINI command?
demiller9 is offline   Reply With Quote
Old 4th September 2011, 21:35   #4
Rajada
Junior Member
 
Join Date: Mar 2011
Posts: 14
To be honest, I acquired the main installer source code from a friend who didn't want to work on it anymore. The flush ini function is nowhere to be found in the script. What is its usage and what effects does it have?

My OS is Windows 7, but the same problem has been confirmed on machines as old as Windows XP. The installer runs as an administrator by default. The ini is installed to a user chosen directory that is confirmed to have a prerequisite application. I can open the ini before, during and after installation and confirm that the non-zero value is there, it just seems like it is being ignored.

This is the tidbit of code that I think is most relevant.

code:
Function checkUpdaterINI

IfFileExists "$INSTDIR\Updater2\updater.ini" 0 copy
${ConfigRead} "$INSTDIR\Updater2\updater.ini" "LastUpdate = " $R1

${If} $R1 >= 17 ; Skip INI, leave it alone
; Greater than or equal to INI number
Goto done

${Else} ; Update INI
; Less than update INI number
Push "$INSTDIR\Updater2\updater.ini" ; file to modify
Push "LastUpdate" ; string that a line must begin with
Push "LastUpdate = 17" ; string to replace whole line with
Call ReplaceLineStr
Goto done
${EndIf}

copy: ; Overide entire INI
SetOutPath "$INSTDIR\Updater2"
File "NerfCP\Updater2\updater.ini"
Goto done


done:

FunctionEnd

Rajada is offline   Reply With Quote
Old 4th September 2011, 22:28   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Use ReadINIStr/WriteINIStr if possible. I'm not sure this still applies to Windows 7 but on 9x INI files were cached in memory and so you had to use FlushINI to write the buffers to disk.

Stu
Afrow UK is offline   Reply With Quote
Old 5th September 2011, 05:47   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Quote:
Originally Posted by Rajada View Post
The flush ini function is nowhere to be found in the script. What is its usage and what effects does it have?
As is often the case, it's all in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.8

Quote:
Originally Posted by Rajada View Post
The installer runs as an administrator by default.
There's no such thing as a default admin. If you need admin you have to enforce it (using the userinfo plugin in .onInit for example).
MSG is offline   Reply With Quote
Old 5th September 2011, 06:05   #7
Roger_wgnr
Junior Member
 
Join Date: May 2010
Posts: 11
What code is in the ReplaceLineStr function? this is where the INI actually gets updated from what I see. You push values to the stack and Call ReplaceLineStr, I imagine that the values are Pop'd in this function and the INI updated.
Roger_wgnr is offline   Reply With Quote
Old 5th September 2011, 08:10   #8
Rajada
Junior Member
 
Join Date: Mar 2011
Posts: 14
Well here's the thing, this installer was coded with a very old version of NSIS. My thought is I should rewrite this now to use WriteIniString like my other updated bits of code and include the flushing function. If that doesn't solve the problem I'll have to do more digging.

And sorry about the confusion, it installs components fine with the current user account settings, so I know that isn't the issue. All I meant is that it asks on all systems I've tested to install as an administrator and works fine every time.
Rajada is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
ini, installer, number

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump