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:
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.
Next time: Allowing the user to customize where this data goes, and whether to install it or not.
Edit: It's up.
Source: {src}\data\*; DestDir: C:\MyCompany\data;
Flags: external recursesubdirs skipifsourcedoesntexist onlyifdoesntexist uninsneveruninstall;
Permissions: users-modifyI'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. DestDirwill 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: externalmeans the files should be present when the installer runs, not when it is compiled.recursesubdirsmeans get all the sub-directories and their contents, too.skipifsourcedoesntexistmeans don't show a message if there are no files in the source data/ directory to be found.onlyifdoesntexistmeans 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.uninsneveruninstallmeans 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-modifyis 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.
Next time: Allowing the user to customize where this data goes, and whether to install it or not.
Edit: It's up.
Comments