mstaton
Posts: 17
Joined: Wed Apr 22, 2009 2:24 pm

Installing SQL Server

The recommended way to install SQL Server is to set it as a prerequisite. We need more control over the dialogs than the prereqs give us, so we would like to install SQL Server 2005 Express from within the installer using a custom action when the user clicks a button. Is there any way to do this?
alavoler
Posts: 45
Joined: Thu Mar 12, 2009 4:29 pm
Location: France
Contact: Website

Re: Installing SQL Server

It's strange but it is possible:

Quickly:

In Custom Action:
UI custom action > New custom action > RunAs Admin ( choose the exe install for sql server ( recommand if exist only bootstrap download over internet the full install) or user Exe with working dir...

In Dialog:
Use PushButton, in Published event:
create new event: Name: Do Action , Argument: [YourCustomAction]


But for your information:
The prerequisites permit to force or not the installation...

Bye
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installing SQL Server

Hi,

Please note that the User Guide contains the Execute custom action on button push how-to which may help you. Since the SQL Server installer needs to be present on the machine when the custom action runs, you can add it as a temporary file.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mstaton
Posts: 17
Joined: Wed Apr 22, 2009 2:24 pm

Re: Installing SQL Server

Thanks for the replies. I will try the Run as Admin trick. Executing the file with command line arguments on button push was not a problem - I had that. But the file would succeed when I did it myself from the command line, but would fail when executed from the installer. Even though I am using /qn I suspect there is still an interaction with part of the installer being .msi based. I am using the sqlexpr32 file, don't know if I need to extract the setup.exe out of that and make my own installer from there.

I will try running as admin and see if that works. If that doesn't, wondering if it would be different if I had a c# program that executes it on a different thread, and execute my c# program from the button push instead of the sql installer itself.

Thanks again. I am very grateful for the help to figure this process out.
mstaton
Posts: 17
Joined: Wed Apr 22, 2009 2:24 pm

Re: Installing SQL Server

OK, RunAsAdmin installs. One last problem (I hope it's the last one!): I need to use the DB after it is installed. Even though I have checked the "Synchronous execution, check return code" option for the RunAsAdmin custom action, it seems to return immediately. I was hoping to RunAsAdmin, then re-enable the Next button, then the user can go on. As it is, the RunAsAdmin returns right away, while the sql server install is still going. In order on the button push, I disable the Next button, DoAction -> RunAsAdmin, then re-enable Next. The Next button is re-enabled right away, so the user will click Next right away, and the installer is going to try to run SQL scripts before the DB server is installed. Is there a delay, or a way to wait until a search condition is true, or a way to only spawn a new dialog when the install is done, or some other way to make the user has to wait while the sql server install is running?

One more note:
I thought perhaps running sqlexpr32.exe was my problem because it extracts the files and then setup.exe is the actual installer. So I first ran an attached custom action to extract the files to the Temp folder, then RunAsAdmin to run the newly extracted setup.exe. But it still returns right away, leaving the install to run in the background. My command line for setup.exe is: /qn ADDLOCAL=ALL DISABLENETWORKPROTOCOLS=0 SECURITYMODE=SQL. I would be fine with seeing a progress bar, I just don't want the user to have to answer any questions.

So - how to make the user wait while SQL Server is installed via RunAsAdmin?

Thanks again for your help.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installing SQL Server

Hi,

Unfortunately the SQL Server installer uses a launcher, so the original custom action process will stop before the install is finished. A solution would be to use a custom action to check if the SQL Server files were installed and block the next dialog until the files are on disk. Please note that the User Guide contains a how-to which may help you.

The custom action in the how-to shows a message to the user, but you can use another custom action before it to check the existence of the files. You can find some sample VBScript code here. This custom action can set an installer property if the files are found and the property can be used to condition the next dialog.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mstaton
Posts: 17
Joined: Wed Apr 22, 2009 2:24 pm

Re: Installing SQL Server

I got to wondering later last night - could this be accomplished using a "start /wait" command?
mstaton
Posts: 17
Joined: Wed Apr 22, 2009 2:24 pm

Re: Installing SQL Server

cosmin,

Is there a way to have RunAsAdmin call the "start /wait sqlexpr32..." command instead of just the sqlexpr32 executable? Maybe through a batch file? Alternatively, would it be reasonable to write my own little c# executable that launches sqlexpr32 and then launch my executable from the installer?

Thanks -
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installing SQL Server

Hi,
Is there a way to have RunAsAdmin call the "start /wait sqlexpr32..." command instead of just the sqlexpr32 executable?
You can try this, but I'm not sure if it will work. Most likely it will wait for the launcher process to finish, just like the custom action does. The "RunAsAdminFile" property can be set to "cmd.exe" and the "RunAsAdminCmd" property can be set to something like this:

Code: Select all

/C "start /wait C:\SQLEXPR32.EXE"
Alternatively, would it be reasonable to write my own little c# executable that launches sqlexpr32 and then launch my executable from the installer?
Yes, a C# executable could launch the SQL server installer and wait for it to finish. The EXE can be launched from the UI like any other custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”