使用process.start从安装程序路径安装应用程序

时间:2014-07-13 03:22:31

标签: vb.net process.start

您好我如何安装应用程序,例如它存储在C:\ Temp \ Filename \ Filename \ abc.exe中并使用process.start。这是我的代码

    Dim wi = WindowsIdentity.GetCurrent()
    Dim wp = New WindowsPrincipal(wi)
    Dim path = "C:\Temp\Unzip\IDGo800_Minidriver_32.zip\IDGo800_Minidriver_32"
    Dim runAsAdmin As Boolean = wp.IsInRole(WindowsBuiltInRole.Administrator)

    If Not runAsAdmin Then

        ' The following properties run the new process as administrator
        Dim startInfo As New ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase)
        startInfo.FileName = "C:\Windows\System32\cmd.exe"
        startInfo.Arguments = "msiexec /i " & path & "\IDGo800_Minidriver_64.msi"" ALLUSERS=1 /qn /norestart"""
        startInfo.WindowStyle = ProcessWindowStyle.Normal
        startInfo.UseShellExecute = True
        startInfo.Verb = "runas"
        Dim myProcess As Process = Nothing
        Try
            myProcess = Process.Start(startInfo)
            Do
                If myProcess.HasExited Then
                    Console.WriteLine("Install complete")
                End If
            Loop While Not myProcess.WaitForExit(1000)
        Catch ex As Exception
            MsgBox(ex)
        End Try
    End If

1 个答案:

答案 0 :(得分:0)

已经回答了问题。

startInfo.Arguments = "/c msiexec /i " & path & "\IDGo800_Minidriver_64.msi"" ALLUSERS=1 /qn /norestart"""