I'm About to Give Up on InnoScript - Part 1

Started by tomb, November 28, 2007, 06:29:15 AM

Previous topic - Next topic

Randem

APPDATA is for each USER not each machine...
 
What do you mean userappdata is returned in Inno Setup?????

Tom Buggy

WOW - not your everyday code!!!  So every computer has its own APPDATA Path.  
 
Tell you what - I've got exactly one Vista user right now.  He's in Michigan and won't be installing this golf application until Spring, as will be the case for most all new or current users who have Vista.  I'm going back to what worked with XP - {app} versus {userappdata} with the data in a subfolder of the installation folder.  That way I can hard-code the public variable that has the path to the data.  I'll work on Vista and {userappdata} later.
 
A curiosity -- why can't/doesn't Inno Setup determine the APPDATA Path on the installed-to machine when {userappdata} is used?

Randem

use these function to get the APPDATA path
 
Private Declare Function GetUserProfileDirectory Lib userenv.dll Alias GetUserProfileDirectoryA (ByVal hToken As Long, ByVal lpProfileDir As String, lpcchSize As Long) As Boolean
Private Declare Function GetCurrentProcess Lib kernel32 () As Long
Private Declare Function OpenProcessToken Lib advapi32 (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
 
 
Public Function GetAppDataFolder() As String
Dim sBuffer As String
Dim hToken As Long
Const TOKEN_QUERY = (&H8)
 
    sBuffer = String(255, 0)
    OpenProcessToken GetCurrentProcess, TOKEN_QUERY, hToken
    GetUserProfileDirectory hToken, sBuffer, 255
    GetAppDataFolder = FixPath(StripTerminator(sBuffer)) & Application Data
 
 
End Function
 
Public Function StripTerminator(sInput As String) As String
    Dim ZeroPos As Long
    ZeroPos = InStr(1, sInput, Chr$(0))
    If ZeroPos > 0 Then
        StripTerminator = Left$(sInput, ZeroPos - 1)
    Else
        StripTerminator = sInput
    End If
End Function

Randem

What OS are you using XP and Vista have APPDATA in the environment. If not you can use an API to get the users Profile area and append Application Data to it.

Tom Buggy

What is your APPDATA path?
 
That's what I want to know!!!  Given the statement in the script I thought that setup created the path and placed the data files in it - I guess not.  I just checked the Environment Variables on the installation computer and there is no APPDATA.  How do I, or more importantly the users, create it?  Once that's resolved then I guess I have to copy the data there in the app startup (something I thought Setup would do).
 
All users will have the same data.  I'm not sure what you mean by install in the ALL USERS Application Data folder.
 
I have discovered the Inno SETUP Help doc and have been reading it.  I think I've commented out in the script the things in [UninstallDelete] that would remove the data.  As for the [Dirs} section, uninsalwaysuninstall does the uninstall ONLY if the folder is empty.
 
As for the list of files in the app folder, it's a hangover in the templete from a previous misinterpretation.  I'll changed to what you posted.
 
BTW, in preparation for all of this I have already modified the app to use Environ(APPDATA) to get a public constant that is now part of every file access via Connection String or Open.  Now if I could only install the app and the data.........

Randem

Why are you listing each file in your app folder to be deleted separately when you could just delete the files and the folder in one line?
 
Type: filesandordirs; Name: {app}
 
Or is there other files in that folder that you want to keep?

Randem

What is your APPDATA path? that is where you should check for the data files you copied. What I like to do is to install the data into the {App} folder then on program start copy the data to where it needs to be if it is not already there. This would handle multiple users using the system and each having different data of their own (in their own profiles). If all user are supposed to share the same data then you would install in the ALL USERS Application Data folder.
 
Yes the data will be removed from the appdata folder if you don't change the flags in the [uninstalldelete] section to that folder. You could also set a flag to ask the user if they want to delete the data upon uninstall. Which I probably should make the default.
 
Yes, I did see the script.

Tom Buggy

I understand what you just said but your are correct about me being confused.  I am especially confused about how the APPDATA path gets generated and what I do in the script to have the data placed there.
 
What I want to acheive is to separate the data from the installation folder and get it to whatever folder {userappdata} puts it.  I thought the presence under [Files] of
 
Source: C:GHMDATA*.*; DestDir: {userappdata}SportsWare Ltd.GHMGHMDATA; Flags: ignoreversion  
would do that but it didn't (I couldn't find the data files anywhere after install).
 
With respect to the always uninstall I misspoke - given that the data is separate from the Program FilesGHM installation folder, I don't care if the installation folder is removed on uninstall.  What I'm concerned about is the last two lines of the [Dir] section because they seem to mean that the data will be removed.  Or do they just mean that the APPDATA path specification is being removed?
 
Have you seen the script I resent?  I apologize for the dicumentation confusion.  I didn't pick up that you were referring to Inno Setup (versus InnoScript) documentation.

Randem

{app} = Installation folder
{userappdata} = APPDATA path
 
These location are not inter-changeable...

Randem

When normal apps uninstall they should clean up after themselves and remove everything it created hense the flag uninsalwaysuninstall. BTW, the flag is covered in the Inno Setup documentation. That's the way it should work. Why would you want to leave the folder GHM after an uninstall?
 
If you used {userappdata} That's where the data went. If you wanted the folder under the installation folder you should have used {app}. You are still very confused. This is one of those times when pen and paper does wonders by writing the locations and where the information is going.

Tom Buggy

The attachment didn't get attached - trying again.

Randem

Yes, The setup will create the folder located in DestDir:
 
I can't tell anything without seeing your script...(No attachment)

Tom Buggy

Well, either my assumptions above are not valid or I'm preparing the script incorrectly.  Here's what I've done:
 
-- Created the folder GHMDATA on the development computer and placed my data files in it.
-- Added C:GHMDATA via Add Folders
-- Modified [UninstallDelete] and [Dirs] via Template
-- Modified the script in Inno Setup to delete the last two items in [Dirs]
 
With respect to the last thing above, I could not comment out the last two lines in [Dirs] with the & prefix.  The generated script contained the &'s - ?? (and I tripled-checked that the template entry matched the script entry)
 
When I ran the Setup on my Virtual XP system (non-development computer) I did not get a GHMDATA subfolder under GHM, did not get a SportsWare Ltd. folder, and I could not find the data files anywhere on the machine.  Do I need to specify those folders in Add Folders? Or, something else.
 
When I uninstalled the Program FilesGHM folder was deleted.  Is my [UninstallDelete] section faulty?
 
Why is Flags: uninsalwaysuninstall genereated in the [Dirs] section of the script?  (By the way, the online and pdf documentation does not cover this section.)
 
A zipped text file of the generated script is attached.

Tom Buggy

With respect to the Application Data Path, my assumption is that {userappdata} in the script is what creates the path which is then retrieved from Environ(APPDATA).  I also assume that if I have the following in the script under [Files]
 
Source: C:GHMDATA*.*; DestDir: {userappdata}SportsWare Ltd.GHMGHMDATA; Flags: ignoreversion
 
Setup will create the required folders.  Are my assumptions valid?
 
With respect to AllowNoIcons in the documentation, I don't know what doc you are referring to.  I've looked at both the online and pdf doc and there's nothing like you posted.  I also looked at the Help Tab and see nothing that would lead me to what you posted.

Randem

What do you mean it's not where the data is? You do have to put the data there. Why would that be a problem?
 
From Inno Setup Help Documentation:
 
[Setup]: AllowNoIcons
 
Valid values:
 yes or no  
 
Default value:
 no  
 
Description:
 
When set to yes, Setup will display a Don't create a Start Menu folder check box on the Select Start Menu Folder wizard page, which allows the user to skip creation of program shortcuts. Note that this check box does not affect [Icons] entries that have Tasks parameters since they have their own checkboxes.