通过MSI安装程序无人参与安装Server2008 [英] To unattend install server2008 by msi setup

查看:83
本文介绍了通过MSI安装程序无人参与安装Server2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建server2008的配置文件和批处理文件.
我的配置文件如下:-
------------------------

I create configuration file of server2008 and batch file.
My config file is below :-
------------------------

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 :-
-----------------------

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


通过运行项目调试器,以上两个功能可以很好地工作在无人参与模式下安装server2008.
-------------------------------------------------- -----------------------------

但是,当我通过安装程序类创建msi安装程序时,请不要以无人参与模式安装server2008.
我的安装程序代码是:-
--------------------


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 :-
--------------------

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


我将如何通过MSI设置解决上述问题????
请帮助我任何指示....


How will i solve the above problem by msi setup????
please help me any instruction....

推荐答案

我知道这个问题并不新鲜,您现在可能已经自己解决了.但是我要做的第一件事就是更改行:

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:

myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden



至:



to:

myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal



这样一来,如果/如果启动Setup2008.bat,您会看到什么情况.

-Pete



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

- Pete


Visual Studio安装项目不支持从项目.MSI内部启动.MSI安装.另外,并非所有版本的Windows Installer一次都支持运行多个安装.启动SQL安装时,它可能会失败,因为它说另一个安装已在进行中.

解决该问题的方法是编写一个.EXE包装,该包装首先启动SQL安装,等待其完成,然后启动项目安装.
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.


这篇关于通过MSI安装程序无人参与安装Server2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆