通过VB.Net应用程序运行MariaDB软件包安装

时间:2020-09-21 10:18:34

标签: vb.net mariadb windows-installer registry

我想从VB.Net应用程序运行MariaDB安装。

首先,我想找出是否已安装MariaDB,并获取Install目录。

Registrykey中的Versionnumber是否有通配符? 目前,我得到这样的Installdirectory,但它仅适用于该版本:

Private Function GetMariaDBInstallDir() As String
Dim KeyValue As String = "Not installed"
    Try
        Dim baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
        Dim regkey = baseKey.OpenSubKey("SOFTWARE\MariaDB 10.4 (x64)")
        If regkey IsNot Nothing Then KeyValue = CStr(regkey.GetValue("INSTALLDIR"))
    Catch ex As Exception
    End Try
    Return KeyValue
 End Function

如果未安装MariaDB,我只是想像这样安装DBInterface:

Dim InstallerPath = """" & My.Application.Info.DirectoryPath + "\mariadb.msi"""
Dim p As Process = New Process()
p.StartInfo.FileName = "msiexec"
p.StartInfo.Arguments = "/i " & InstallerPath & " INSTALLDIR=C:\MyApp\subfolder\MariaDB REMOVE=ALL ADDLOCAL=DBInstance REBOOT=ReallySuppress /passive"
p.Start()
p.WaitForExit()
Path2MariaDB = "C:\MyApp\subfolder\MariaDB\"

但是这不起作用,所以第二个问题是,如何修复MariaDB安装?

最后,我想做的就是像这样为我的应用程序创建一个数据库实例:

Dim p2 As Process = New Process()
p2.StartInfo.FileName = Path2MariaDB & "bin\mysql_install_db.exe"
p2.StartInfo.Arguments = "--datadir=c:\MyApp\mariadb --service=MyAppDB --password=" & password & " --port=" & port & " --socket=myapp --allow-remote-root-access"
p2.Start()
p2.WaitForExit()

最后一个问题是,这是为MyApplication创建新的DBInstance的正确语法吗?

谢谢:)

0 个答案:

没有答案