Démarrer / Arréter un processus

sadok_sa Messages postés 21 Date d'inscription jeudi 30 octobre 2003 Statut Membre Dernière intervention 7 mai 2009 - 6 sept. 2006 à 09:22
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 - 7 juil. 2012 à 19:26
Pouvez vous m'aider à trouver
2 fonctions : 





<!--[if !supportLists]-->


-        


<!--[endif]-->

De démarrage d'une application avec ou sans paramètres








Exp:


Demarrer_App ("notepad.exe",
"readme.txt").






<!--[if !supportLists]-->


-        


<!--[endif]-->


D'arrêt d'un processus de l'application ouverte









Exp:


Areter_App ("notepad.exe).







 

Merci pour votre aide






 


e-mail:
[yosri.BELHAJRHOUMA@TUNISAIR.COM.TN yosri.BELHAJRHOUMA@TUNISAIR.COM.TN]

9 réponses

cs_fauve Messages postés 661 Date d'inscription vendredi 2 décembre 2005 Statut Membre Dernière intervention 23 mars 2011 8
18 mars 2007 à 10:32
Salut,

Tout d'abord, il faut rajouter avant Public Class : Imports
System.Diagnostics

Pour démarrer une application :

Dim monprocess As New Process()


Process.Start("notepad.exe", "C:\monPath\Fichier.txt") ' Ouvre le fichier Fichier.txt avec notepad

Pour arrêter une application :

Dim
ProcessusCourant As Process = Process.GetCurrentProcess() ' Récupère tous les processus locaux

For i As Integer = 0 To ProcessusCourant.Length - 1 ' Parcoure tous les processus trouvés
    if ProcessusCourant(i).ProcessName = "notepad.exe" ' Si un processus s'appelle notepad.exe
       ProcessusCourant(i).Kill() ' On tue ce processus (Arrêt de notepad)
    End If
Next i
1
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
6 sept. 2006 à 09:34
Process.Start

Renfield
Admin CodeS-SourceS- MVP Visual Basic
0
irsoy Messages postés 18 Date d'inscription mercredi 7 février 2007 Statut Membre Dernière intervention 4 juillet 2008
16 mai 2007 à 08:43
Public Sub DemarrerApplication(ByVal NomApplication$, Optional ByVal ParametresApplication$ = "")
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ DEMARRERAGE DE L'APPLICATION ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        Try
            Dim Processus As New System.Diagnostics.Process()
            If NomApplication <> String.Empty And ParametresApplication <> String.Empty Then
                With Processus
                    'Nom de l'executable à lancer.
                    .StartInfo.FileName = NomApplication
                    'Argument a passer
                    .StartInfo.Arguments = ParametresApplication
                    'Démarrage du processus.
                    .Start()
                End With
            Else
                With Processus
                    .StartInfo.FileName = NomApplication
                    .Start()
                End With
            End If
        Catch ex As Exception
            Log.Text &= "[" & My.Computer.Clock.GmtTime.ToString & "]> Erreur DemarrerApplication: " & ex.Message & vbCrLf
         End Try
    End Sub

    Public Sub ArreterApplication(ByVal Application$)
        ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ARRETER APPLICATIONS ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        Try
            For Each Processus As Process In Process.GetProcesses()
                If Processus.ProcessName.EndsWith(Application) Then
                    With Processus
                        .Kill()
                        .Close() 'Libération des ressources
                    End With
                End If
            Next
        Catch ex As Exception
            Log.Text &= "[" & My.Computer.Clock.GmtTime.ToString & "] Erreur ArreterApplication: " & ex.Message & vbCrLf         
        End Try
    End Sub
-----------------------------------------------
En Informatique, tout est possible...
mais...
A+
0
cytil29 Messages postés 8 Date d'inscription mardi 31 octobre 2006 Statut Membre Dernière intervention 18 août 2011
19 févr. 2011 à 18:17
salut,

Le mieux reste quand même :
'---------------------------------------------------------------------------
sub stopproc(ByVal namepro As String)
Dim sProcess() As Process
sProcess = Process.GetProcessesByName(namepro)
For i = 0 To sProcess.Length - 1
sProcess(i).Kill()
Next
sub Function
'---------------------------------------------------------------------------

Enjoy
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cytil29 Messages postés 8 Date d'inscription mardi 31 octobre 2006 Statut Membre Dernière intervention 18 août 2011
19 févr. 2011 à 18:20
Arg, a la bas c'était une foncition, j'ai vous vite fais remplacer par un Sub et j'ai fais un erreur : "sub function", je voulais bien sur mettre "End Sub"

Sub stopproc(ByVal namepro As String)
Dim sProcess() As Process
sProcess = Process.GetProcessesByName(namepro)
For i = 0 To sProcess.Length - 1
sProcess(i).Kill()
Next
End Sub
0
hachani1987 Messages postés 1 Date d'inscription samedi 14 janvier 2012 Statut Membre Dernière intervention 18 janvier 2015
11 mai 2012 à 17:47
salut
j'ai une application exécuté avec DOS "cmd.exe"
et dans mon frame j'ai une bouton pour fermer cette application


comment faire s.v.p
?????????????????????????????????
0
Utilisateur anonyme
12 mai 2012 à 03:05
Bonjour

Exit
0
cc125 Messages postés 14 Date d'inscription mardi 1 mai 2012 Statut Membre Dernière intervention 15 novembre 2013
7 juil. 2012 à 19:21
Faut-il remplacer namepro par le nom du logiciel????

/A.F.D.Gbug\
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
7 juil. 2012 à 19:26
Bonjour, cc125,
Si tu veux ... mais pourquoi pas par un rhinocéros ? ou le jeu de la marelle ?
Au hasard, donc (mais je m'interroge sérieusement) : par l'exécutable ...
Dur ? ===>> dur dur !


________________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches.
Pas d'aide en ligne installée ? => ne comptez pas sur moi pour simplement vous dire ce qu'elle contient. Je n'interviendrai qu'en cas de nécessité de développ
0
Rejoignez-nous