views:

53

answers:

2

I've written an app which bootstraps SQL Express 2008 with a Wix 3.5 installer, then attempts to CREATE DATABASE on first run of the app. The install of SQL Express is thus totally unattended. This all works fine when the account installing the app is an Administrator on the machine.

However, somewhat unsurprisingly, problems arise when installing as non-admin. When we try to run CREATE DATABASE sql it squarks -

sql express 2008 create database permission denied in database 'master'

Obviously the standard user account doesn't have the correct privilege. So somehow we need to grant the standard user the correct privs. I have thought of bundling a separate executable which is forced to run as Admin (via UAC) which would create the database and assign privileges on the new database to the user account - not a very elegant solution.

This seems like an obvious thing you'd want to do when deploying an app but there seems to be a dearth of information on the subject. Looking for suggestions - thanks.

+1  A: 

It is a fairly usual prequisite that when installing an app, you need to be an administrator on the machine you are installing it. Why can you simply not make it a prequisite? Most sysadmins don't want their non admin users installing apps anyway.

Ben Robinson
Yes the program requests admin to install, but the first time the program is run (i.e. not as admin) the database does not yet exist.So I suppose the solution is to write a post-install script to create the db?
PhilG
Yes that would be the solution. Otherwise you would have to give the user of the app create database permisions on the SQL server which seems excessive.
Ben Robinson
+1  A: 

Turns out you can do all of this with WiX, with the SQL Extension.

http://www.tramontana.co.hu/wix/lesson7.php#7.1

PhilG