So for the next release of our software, we need our installer to create a folder that’s writable by all users on the computer.
You’d think this wouldn’t be hard. You’d think this would be well-trod ground. But no, apparently not. We’re using an MSI-based installer, nice feature set, rather pricey, which apparently can’t grant permissions to the standard “Users” group because it claims that group doesn’t exist. (We’ve filed a bug report and are waiting to hear back.) And our attempt to write a little app to set the permissions programmatically isn’t going well either. I’m not actually the developer who’s working on installation issues (I just get some questions bounced off me now and then), but it seems to be causing rapid hair loss — not from ripping hair out, just from the friction caused by banging against brick walls. I’ve looked at the permission APIs before, and they’re pretty awful; according to my cohort, the documentation is even worse, basically amounting to “take a guess at the parameters and see if it works”.
Freeware to the rescue.
My boss suggested that I take a quick look at Jordan Russell’s Inno Setup, a freeware (with source) installation-building package that I had some prior experience with, and see if it could handle permissions. It originally took me a while to get used to Inno, since you have to write a text-based install script. The first time I downloaded it (around five years ago), I took a look at it and then uninstalled it — I made the mistake of being unimpressed by its lack of a pretty design-time GUI. (It has syntax highlighting now, which helps, but you still write your script as a text file.) But it’s powerful, and it can do just about anything; it’s even got a built-in scripting language. Jordan pays attention to building good apps (none of that “every time the user clicks the Next button, we’ll hide the current dialog box and then show another one, and hope nobody notices the flickering” crap like Wise and InstallShield both seem to be doing these days), and of course free is good. But can it change permissions?
Of course it can change permissions. Yes, it can grant modify access on a given folder to all users of the computer (I just tested it to make absolutely sure that it works, and it does, even on the same PC where the expensive installer didn’t work). You just tack “; Permissions: users-modify” onto the entry in the [Dirs] section. So, while we probably won’t switch our installer to Inno at this point, we do have ready access to source code (Delphi, no less) for changing permissions.
As if that weren’t cool enough, the FAQ on the Inno Setup web site suggested taking a look at SetACL, an open-source, command-line tool for changing file permissions. SetACL.exe (command-line version) is 258K — which seems awfully large for a C++ console app — but its list of command-line parameters is pretty substantial; it can set permissions on files, folders, printers, Registry entries, services, and network shares, and it’s full of options I’ve never even heard of. I think, between Inno and SetACL, that our permission problems should be pretty well wrapped up. And there was much rejoicing.