Inno Setup user data directory

One of the requirements we have for an installer is to create a user data directory. We'd like the installer to create C:\MyCompany\data\, and copy any data we decide to give this customer on their install DVD into that new folder. VS 2005 Install projects couldn't do it without a custom action. Here's how in Inno Setup:

Source: {src}\data\*; DestDir: C:\MyCompany\data;
   Flags: external recursesubdirs skipifsourcedoesntexist onlyifdoesntexist uninsneveruninstall;
   Permissions: users-modify


I've put that on multiple lines so it's easier to read, but it's all one line in the .iss file. Let's take a look at what each of those pieces mean.
  • First, that '*' in the Source: field is magic. It means it will go and find whatever is there in the data\ directory next to your setup.exe. It must be combined with the Flags: external, so that Inno Setup knows not to look for it when your script is compiled.
  • DestDir will be created by the installer, and files copied in. I've hard-coded the directory name in this example, but what we actually do I will discuss in my next Inno Setup post - we let the user choose.
  • Flags: external means the files should be present when the installer runs, not when it is compiled.
  • recursesubdirs means get all the sub-directories and their contents, too. 
  • skipifsourcedoesntexist means don't show a message if there are no files in the source data/ directory to be found.
  • onlyifdoesntexist means don't replace files if they are already on the user's system. This is useful for updating data - you don't want to over-write files the user may have worked on and modified. 
  • uninsneveruninstall means don't remove these files when your app is un-installed. During an upgrade, you might uninstall the previous version, and you don't want sample/tutorial data files to disappear!
  • Permissions: users-modify is also very cool - since we are not installing into My Documents (because our data is big and we want everyone to share the data), we have to make sure user-level accounts (i.e. non-administrator) can edit and save the data. Just tack that on, and every file/directory copied will be modifiable by all the users on this computer, even if it's installed by an admin.
Note that I'm working with ISTool and Inno Setup version 5.3, so double-check if your version is different.

Next time: Allowing the user to customize where this data goes, and whether to install it or not.
Edit: It's up

Comments

Popular posts from this blog

Inno Setup custom data directory location

OpenEmbedded Angstrom for Advantech PCM-9375

Inno Setup MSVC vcredist without bothering your users