Lancer un executable avec un bouton

campa71 Messages postés 2 Date d'inscription lundi 26 janvier 2009 Statut Membre Dernière intervention 13 décembre 2010 - 6 déc. 2010 à 17:21
lediablo Messages postés 214 Date d'inscription mercredi 26 avril 2006 Statut Membre Dernière intervention 2 août 2012 - 13 déc. 2010 à 17:09
Bonjour,

je souhaite lancer une application à partir d'un bouton sur mon form1.

Le raccourci bureau de l'appli lance une commande du type :

"chemin_exe_1.exe" -run "exe_2.exe" -env nom_fichier_environnement -direnv "chemin_fichier_env" -nowindow

j'ai essayé d'intégrer ce chemin d'accès directement derrière un shell en faisant :

dim MonAppl

MonAppl = shell ( "chemin_exe_1.exe" -run "exe_2.exe" -env nom_fichier_environnement -direnv "chemin_fichier_env" -nowindow , 3)

Mais sans succès

Comment lancer la ligne de commande complète ?

Merci d'avance pour votre aide.

4 réponses

cs_breton51 Messages postés 78 Date d'inscription jeudi 21 avril 2005 Statut Membre Dernière intervention 15 novembre 2018
6 déc. 2010 à 18:27
utilise la class process()


    Public Sub execute_ligne(ByVal chemin_et_exe As String, Optional ByVal argument As String = Nothing)
        Try
            Dim monProcess As New Process()
            monProcess.StartInfo.FileName = chemin_et_exe
            If argument <> Nothing Then
                monProcess.StartInfo.Arguments = argument
            End If
            monProcess.Start()
            monProcess.Close()
        Catch ex As Exception
            'traitement en cas d'érreur
        End Try
    End Sub



0
campa71 Messages postés 2 Date d'inscription lundi 26 janvier 2009 Statut Membre Dernière intervention 13 décembre 2010
13 déc. 2010 à 13:10
Bonjour,

je vais essayer avec ce code.

Merci pour ton aide
0
lediablo Messages postés 214 Date d'inscription mercredi 26 avril 2006 Statut Membre Dernière intervention 2 août 2012
13 déc. 2010 à 17:05
salut
c'est la catégorie VB6 et pas vb.net
utilise
shell "chemin du exe" ou shellexecute


Quand on pose une question on est con 5 minutes,Quand on ne la pose pas on le reste toute sa vie (mon site)
0
lediablo Messages postés 214 Date d'inscription mercredi 26 avril 2006 Statut Membre Dernière intervention 2 août 2012
13 déc. 2010 à 17:09
exemple shelexecute:

      Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

      Private Sub Command1_Click()
          ShellExecute 0, "Open", "C:\test.exe a -r -ep1 -v", vbNullString, vbNullString,vbHidden
      End Sub



Quand on pose une question on est con 5 minutes,Quand on ne la pose pas on le reste toute sa vie (mon site)
0
Rejoignez-nous