Hi Guys,

I have a main application, a class library and a setup project that has the primary output of both the above.

The class library has a class that determines if dql server 2005 express is installed and if not it installs sql server express. here is a code snippet:

Code:
Private Function BuildCommandLine() As String
        Dim strCommandLine As StringBuilder = New StringBuilder

        If (Not String.IsNullOrEmpty(m_installSqlDir)) Then
            strCommandLine.Append("INSTALLSQLDIR=""").Append(m_installSqlDir).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_installSqlSharedDir)) Then
            strCommandLine.Append("INSTALLSQLSHAREDDIR=""").Append(m_installSqlSharedDir).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_installSqlDataDir)) Then
            strCommandLine.Append("INSTALLSQLDATADIR=""").Append(m_installSqlDataDir).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_addLocal)) Then
            strCommandLine.Append(" ADDLOCAL=""").Append(m_addLocal).Append("""")
        End If

        If (m_sqlAutoStart) Then
            strCommandLine.Append(" SQLAUTOSTART=1")
        Else
            strCommandLine.Append(" SQLAUTOSTART=0")
        End If

        If (m_sqlBrowserAutoStart) Then
            strCommandLine.Append(" SQLBROWSERAUTOSTART=1")
        Else
            strCommandLine.Append(" SQLBROWSERAUTOSTART=0")
        End If

        If (String.IsNullOrEmpty(m_sqlBrowserAccount)) Then
            strCommandLine.Append("SQLBROWSERACCOUNT=""").Append(m_sqlBrowserAccount).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_sqlBrowserPassword)) Then
            strCommandLine.Append("SQLBROWSERPASSWORD=""").Append(m_sqlBrowserPassword).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_sqlAccount)) Then
            strCommandLine.Append(" SQLACCOUNT=""").Append(m_sqlAccount).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_sqlPassword)) Then
            strCommandLine.Append(" SQLPASSWORD=""").Append(m_sqlPassword).Append("""")
        End If

        If (m_sqlSecurityMode = True) Then
            strCommandLine.Append(" SECURITYMODE=SQL")
        End If

        If (Not String.IsNullOrEmpty(m_saPassword)) Then
            strCommandLine.Append(" SAPWD=""").Append(m_saPassword).Append("""")
        End If

        If (Not String.IsNullOrEmpty(m_sqlCollation)) Then
            strCommandLine.Append(" SQLCOLLATION=""").Append(m_sqlCollation).Append("""")
        End If

        If (m_disableNetworkProtocols = True) Then
            strCommandLine.Append(" DISABLENETWORKPROTOCOLS=1")
        Else
            strCommandLine.Append(" DISABLENETWORKPROTOCOLS=0")
        End If

        If (m_errorReporting = True) Then
            strCommandLine.Append(" ERRORREPORTING=1")
        Else
            strCommandLine.Append(" ERRORREPORTING=0")
        End If

        Return strCommandLine.ToString

    End Function

    Public Function InstallExpress() As Boolean
        Dim myProcess As Process = New Process
        myProcess.StartInfo.FileName = m_sqlExpressSetupFileLocation
        myProcess.StartInfo.Arguments = "/qb " + BuildCommandLine()

        '     /qn -- Specifies that setup run with no user interface.
        '               /qb -- Specifies that setup show only the basic 
        'user interface. Only dialog boxes displaying progress information are 
        'displayed. Other dialog boxes, such as the dialog box that asks users if 
        'they want to restart at the end of the setup process, are not displayed.

        myProcess.StartInfo.UseShellExecute = False

        Return myProcess.Start

    End Function
My problem is. When I run the setup it must install sql server then run a script that creates the database etc. this is a snippet from my other class:

Code:
ei.InstallExpress()

            Dim success As Boolean = tcon.TestConnection(".\SQLEXPRESS", "master")

            If (success) Then

                tcon.RunAllSqlSriptsInDirectory()

            End If
as you can see I call the InstallExpress function to do the install of sql. Then once that is complete I must run the script to create the database.

However, my setup finsihes while the sqlexpress install is still running and I have a feeling the script gets executed before sql express is installed and I therefore cannot login once I try to oprn my application.

How do I fix this? please please help. when I ran the setup again after sql installed it created my database fine.

***
also if I add code to wait until the sql install process is done and then execute the script, the sql installer fails saying "Another installation is already in progress. Complete that installation before proceeding with this install"

Please please advise me. I worked so hard on this now I'm at a dead end again