Lancer une application

Résolu/Fermé
bolobo46 Messages postés 128 Date d'inscription vendredi 26 juillet 2013 Statut Membre Dernière intervention 1 août 2015 - 10 août 2013 à 16:57
karirovax Messages postés 3221 Date d'inscription dimanche 17 janvier 2010 Statut Membre Dernière intervention 22 juin 2016 - 10 août 2013 à 17:16
Bonjour,
J'aimerais savoir comment lancer une application a partir d'une commande :

If RichTextBox1.Text = "écrire" Then MsgBox("Voulez vous NOTEPAD ou OPENOFFICE ?")
If RichTextBox1.Text = "notepad" Then (je ne sais pas quoi mettre ici pour lancer le bloc note)

merci d'avance :)

1 réponse

karirovax Messages postés 3221 Date d'inscription dimanche 17 janvier 2010 Statut Membre Dernière intervention 22 juin 2016 203
10 août 2013 à 17:16
voici un exemple qui lance la commande ipconfig

Imports System.IO
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ' Setting some of the process information
            Dim start_info As New ProcessStartInfo("C:\WINDOWS\system32\ipconfig")
            start_info.UseShellExecute = False
            start_info.CreateNoWindow = True
            start_info.RedirectStandardOutput = True
            start_info.RedirectStandardError = True
     
            ' Construct the argument for the process
            start_info.Arguments = "/all"
     
            ' Create the new process, set its start information and execute the process
            Dim proc As New Process()
            proc.StartInfo = start_info
            proc.Start()
     
            ' Attach to stdout and stderr.
            Dim std_out As StreamReader = proc.StandardOutput()
            Dim std_err As StreamReader = proc.StandardError()
     
            ' Display the results.
            RichTextBox1.Text = std_out.ReadToEnd() & std_err.ReadToEnd()
     
            ' Clean up.
            std_out.Close()
            std_err.Close()
            proc.Close()
     
        End Sub
    End Class

0