Quantcast
Channel: Visual Basic Tips and Tricks
Viewing all articles
Browse latest Browse all 2212

[VB2015]problemi con Process.Start

$
0
0

 

Salve, ho questo problema che non so come superarlo.... devo fare eseguire delle applicazioni esterne ma nel primo caso con una stringa di questo tipo:

 

"C:\Progra Files\IrfanView\iv_uninstall.exe"

 

mi da errore e dice:

 

Ulteriori informazioni: Per eseguire l'operazione richiesta è necessaria l'esecuzione con privilegi elevati

 

nel secondo caso con parametri aggiuntivi ES:

MsiExec.exe /X{0EFDF2F9-836D-4EB7-A32D-038BD3F1FB2A}

mi si apre la schermata di Windows Installer ed elenca tutti i possibili parametri utilizzabili... questo è il codice che utilizzo

 

 

Private Sub DGV_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGV.CellDoubleClick
       If DGV.Columns(e.ColumnIndex).Name = "Collegamento Uninstaller" Then
           'PanRiepilogo.Visible = False

           Dim Val As String = DGV.Rows(e.RowIndex).Cells(e.ColumnIndex).Value

           If IsDBNull(Val) Then
               Val = "" ' blank if dbnull values
           Else

               If Val.Length > 0 Then
                   If MessageBox.Show("Vuoi veramente disistallare questa applicazione ?",
                                      "Finestra conferma disistaller",
                                      MessageBoxButtons.YesNo,
                                      MessageBoxIcon.Question) = DialogResult.No Then
                       Exit Sub
                   End If
                   Dim Par(1) As String
                   Dim _e As Char() = {"/", "-"}
                   Dim val2 As String = Val.Replace("""", String.Empty)
                   For Each c In _e
                       If val2.Contains(c) Then
                           Par = Split(val2, c)
                           Exit For
                       Else
                           Par(0) = val2
                           Par(1) = ""
                       End If
                   Next
                   Dim startInfo As New ProcessStartInfo(Par(0))
                   startInfo.WindowStyle = ProcessWindowStyle.Minimized
                   If Par(1).Length > 0 Then
                       startInfo.Arguments = Par(1)
                   End If
                   startInfo.RedirectStandardOutput = True
                   startInfo.UseShellExecute = False
                   startInfo.CreateNoWindow = True
                   Dim p = Process.Start(startInfo)
                   Dim result = p.StandardOutput.ReadToEnd()
                   p.Close()
               End If
           End If
       End If
   End Sub

ora chiedo come posso ovviare al problema devo creare un file .Bat ? ho esiste un altra alternativa ?


Viewing all articles
Browse latest Browse all 2212