Click here to Skip to main content
15,887,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create configuration file of server2008 and batch file.
My config file is below :-
------------------------
VB
Private Sub CreateInstallConfigIniFileSQL2008(ByVal filePath As String, ByVal fileName As String)
Dim fs As FileStream
        fs = New FileStream(filePath + "\" + fileName, FileMode.Create, FileAccess.ReadWrite)
        Dim sw As New StreamWriter(fs)
        sw.WriteLine("[SQLSERVER2008]")
        sw.WriteLine("; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance.")
        sw.WriteLine("INSTANCEID = ""MSSQLSERVER""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.")
        sw.WriteLine("Action = ""Install""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components.")
        sw.WriteLine("FEATURES=SQLENGINE,CONN,SSMS,ADV_SSMS")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Displays the command line parameters usage")
        sw.WriteLine("Help = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies that the detailed Setup log should be piped to the console.")
        sw.WriteLine("INDICATEPROGRESS = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Setup will not display any user interface.")
        sw.WriteLine("QUIETSIMPLE = ""True""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.")
        sw.WriteLine("X86 = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Parameter that controls the user interface behavior. Valid values are Normal for the full UI, and AutoAdvance for a simplied UI.")
        sw.WriteLine("; UIMODE=""Normal""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature.")
        sw.WriteLine("ERRORREPORTING = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify the root installation directory for native shared components.")
        sw.WriteLine("INSTALLSHAREDDIR = ""C:\Program Files\Microsoft SQL Server""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify the installation directory.")
        sw.WriteLine("INSTANCEDIR = ""C:\Program Files\Microsoft SQL Server""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature.")
        sw.WriteLine("SQMREPORTING = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS).")
        sw.WriteLine("INSTANCENAME = ""MSSQLSERVER2008""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Agent account name")
        sw.WriteLine("AGTSVCACCOUNT = ""NT AUTHORITY\NETWORK SERVICE""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Auto-start service after installation.")
        sw.WriteLine("AGTSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Startup type for Integration Services.")
        sw.WriteLine("ISSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Account for Integration Services: Domain\User or system account.")
        sw.WriteLine("ISSVCACCOUNT = ""NT AUTHORITY\NetworkService""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Controls the service startup type setting after the service has been created.")
        sw.WriteLine("ASSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The collation to be used by Analysis Services.")
        sw.WriteLine("ASCOLLATION = ""Latin1_General_CI_AS""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The location for the Analysis Services data files.")
        sw.WriteLine("ASDATADIR = ""Data""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The location for the Analysis Services log files.")
        sw.WriteLine("ASLOGDIR = ""Log""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The location for the Analysis Services backup files.")
        sw.WriteLine("ASBACKUPDIR = ""Backup""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The location for the Analysis Services temporary files.")
        sw.WriteLine("ASTEMPDIR = ""Temp""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The location for the Analysis Services configuration files.")
        sw.WriteLine("ASCONFIGDIR = ""Config""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies whether or not the MSOLAP provider is allowed to run in process.")
        sw.WriteLine("ASPROVIDERMSOLAP = ""1""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Startup type for the SQL Server service.")
        sw.WriteLine("SQLSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Level to enable FILESTREAM feature at (0, 1, 2 or 3). ")
        sw.WriteLine("FILESTREAMLEVEL = ""3""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Name of Windows share to be created for FILESTREAM File I/O. ")
        sw.WriteLine("FILESTREAMSHARENAME = ""MSSQLSERVER2008""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Set to 1 to enable RANU for SQL Server Express.")
        sw.WriteLine("ENABLERANU = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies a Windows collation or an SQL collation to use for the Database Engine.")
        sw.WriteLine("SQLCOLLATION = ""SQL_Latin1_General_CP1_CI_AS""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Account for SQL Server service: Domain\User or system account.")
        sw.WriteLine("SQLSVCACCOUNT = ""NT AUTHORITY\NETWORK SERVICE""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Default directory for the Database Engine user databases.")
        sw.WriteLine("SQLUSERDBDIR = ""C:\Program Files\Microsoft SQL Server\100\MSSQL2008\Data""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Default directory for the Database Engine user database logs.")
        sw.WriteLine("SQLUSERDBLOGDIR = ""C:\Program Files\Microsoft SQL Server\100\MSSQL2008\Data\Logs""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Directory for Database Engine TempDB files.")
        sw.WriteLine("SQLTEMPDBDIR = ""C:\Program Files\Microsoft SQL Server\100\MSSQL2008\Data""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Directory for the Database Engine TempDB log files.")
        sw.WriteLine("SQLTEMPDBLOGDIR = ""C:\Program Files\Microsoft SQL Server\100\MSSQL2008\Data\Logs""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express.")
        sw.WriteLine("ADDCURRENTUSERASSQLADMIN = ""False""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies the password for the SQL Server sa account.")
        sw.WriteLine("SAPWD = ""ens""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; The default is Windows Authentication. Use SQL for Mixed Mode Authentication.")
        sw.WriteLine("SECURITYMODE = ""SQL""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify 0 to disable or 1 to enable the TCP/IP protocol.")
        sw.WriteLine("TCPENABLED = ""1""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specify 0 to disable or 1 to enable the Named Pipes protocol.")
        sw.WriteLine("NPENABLED = ""0""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Startup type for Browser Service.")
        sw.WriteLine("BROWSERSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies how the startup mode of the report server NT service. When")
        sw.WriteLine("; Manual - Service startup is manual mode (default).")
        sw.WriteLine("; Automatic - Service startup is automatic mode.")
        sw.WriteLine("; Disabled - Service is disabled")
        sw.WriteLine("RSSVCSTARTUPTYPE = ""Automatic""")
        'sw.WriteLine(Environment.NewLine())
        sw.WriteLine("; Specifies which mode report server is installed in.")
        sw.WriteLine("; Default value: FilesOnly")
        sw.WriteLine("RSINSTALLMODE = ""FilesOnlyMode""")

        sw.Close()
        fs.Close()
End Sub

My batch file is below :-
-----------------------
VB
Private Sub CreateBatFileUninstallSQL2008(ByVal bkupPath As String, ByVal configFileName As String)
        Dim fs As FileStream
        fs = New FileStream(bkupPath + "\Setup2008.bat", FileMode.Create, FileAccess.ReadWrite)
        Dim sw As New StreamWriter(fs)
        sw.WriteLine("@ECHO off")
        sw.WriteLine("echo Installing SQL Server 2008 R2...")
        sw.WriteLine("""" + bkupPath + "\SetupInstallerVB\Dependency Setup\SQL2008 Setup\setup.exe"" /ConfigurationFile=" + bkupPath + "\" + configFileName) '' + " /SQLSYSADMINACCOUNTS=""" + My.Computer.Name + "\Administrator""")
        sw.Close()
        fs.Close()
End Sub

above two function are fine work to install in unattended mode server2008 by run the projects debugger.
-------------------------------------------------------------------------------

But when i create a msi setup through installer class, not install server2008 in unattended mode.
My Installer code is :-
--------------------
VB
Protected Overrides Sub OnBeforeInstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.OnBeforeInstall(savedState)

        System.Diagnostics.Debugger.Launch()
        System.Diagnostics.Debugger.Break()

        Call UnattendedSQL2008InstallByCommandLine()
End Sub
Private Sub UnattendedSQL2008InstallByCommandLine()
        Try
            Dim Path As String = "D:\DCom\SetupInstallerVB"
            Dim myProcess As New Process()

            CreateInstallConfigIniFileSQL2008(Path, "InstallSetup2008.ini")
            CreateBatFileInstallSQL2008(Path, "InstallSetup2008.ini")

            myProcess.StartInfo.FileName = Path + "\Setup2008.bat"
            ''Here we start the process 
            myProcess.StartInfo = New ProcessStartInfo(myProcess.StartInfo.FileName)
            myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            myProcess.StartInfo.RedirectStandardOutput = True
            myProcess.StartInfo.UseShellExecute = False
            myProcess.Start()
            myProcess.WaitForExit()
            myProcess.Close()

            DeleteFile(Path, "\Setup2008.bat")
            DeleteFile(Path, "\InstallSetup2008.ini")

        Catch ex As Exception
            MsgBox("Should be restart computer for SQL Installation...")
            Throw ex
        End Try
End Sub

How will i solve the above problem by msi setup????
please help me any instruction....
Posted
Updated 2-Jul-12 3:46am
v2

I know this question isn't new, and you've probably solved it yourself by now. But the first thing I would have done is change the line:

VB
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden


to:

VB
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal


So you can see what happens when / if Setup2008.bat is kicked off.

- Pete
 
Share this answer
 
The Visual Studio installation project does not support launching an .MSI installation from inside your project .MSI. Also, not all versions of Windows Installer supports having more than one install running at a time. When you launch the SQL installation, it's probably failing because it's say that another install is already in progress.

Your solution to the problem is to write a .EXE wrapper that launches the SQL installation first, waits for it to complete, then launches your project install.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900