Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
lSteph
Bonjour,
Comme son nom l'indique "fermer une application" pas un processus!
A priori ce code utilise la fonction API suivante:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
L'application est un programme lancé dans une fenêtre , donc FindWindow a effectivement faculté à la trouver. Mais pour un processus...
Pour arrêter un processus,
Un userform avec Listbox1,Combobox1,Commandbutton1
'''''*****Code de userform1**** '(code adapté de: http://vb.developpez.com/faq/?page=Systeme) Dim svc As Object Dim myQuery As String Dim myp
Private Sub CommandButton1_Click() KillProcess ComboBox1 End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process" For Each myp In svc.execquery(myQuery) ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath ComboBox1.AddItem myp.Name Next Set svc = Nothing Exit Sub
UIniError: MsgBox "Error " & Err.Number & " (" & Err.Description & ")" Err.Clear End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process where name='" & ProcessName & "'" For Each myp In svc.execquery(myQuery) myp.Terminate Next Set svc = Nothing End Function ''''*********************
'Cdlt.
'lSteph
MK a présenté l'énoncé suivant :
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Merci de votre aide.
MK
-- - -
Bonjour,
Comme son nom l'indique "fermer une application" pas un processus!
A priori ce code utilise la fonction API suivante:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
L'application est un programme lancé dans une fenêtre , donc
FindWindow a effectivement faculté à la trouver.
Mais pour un processus...
Pour arrêter un processus,
Un userform avec Listbox1,Combobox1,Commandbutton1
'''''*****Code de userform1****
'(code adapté de: http://vb.developpez.com/faq/?page=Systeme)
Dim svc As Object
Dim myQuery As String
Dim myp
Private Sub CommandButton1_Click()
KillProcess ComboBox1
End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process"
For Each myp In svc.execquery(myQuery)
ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath
ComboBox1.AddItem myp.Name
Next
Set svc = Nothing
Exit Sub
UIniError:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Err.Clear
End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process where name='" & ProcessName &
"'"
For Each myp In svc.execquery(myQuery)
myp.Terminate
Next
Set svc = Nothing
End Function
''''*********************
'Cdlt.
'lSteph
MK a présenté l'énoncé suivant :
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en
cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt
Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Comme son nom l'indique "fermer une application" pas un processus!
A priori ce code utilise la fonction API suivante:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
L'application est un programme lancé dans une fenêtre , donc FindWindow a effectivement faculté à la trouver. Mais pour un processus...
Pour arrêter un processus,
Un userform avec Listbox1,Combobox1,Commandbutton1
'''''*****Code de userform1**** '(code adapté de: http://vb.developpez.com/faq/?page=Systeme) Dim svc As Object Dim myQuery As String Dim myp
Private Sub CommandButton1_Click() KillProcess ComboBox1 End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process" For Each myp In svc.execquery(myQuery) ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath ComboBox1.AddItem myp.Name Next Set svc = Nothing Exit Sub
UIniError: MsgBox "Error " & Err.Number & " (" & Err.Description & ")" Err.Clear End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process where name='" & ProcessName & "'" For Each myp In svc.execquery(myQuery) myp.Terminate Next Set svc = Nothing End Function ''''*********************
'Cdlt.
'lSteph
MK a présenté l'énoncé suivant :
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Merci de votre aide.
MK
-- - -
MichDenis
As-tu essayer ceci :
Attention, fermeture brutale... on ne te demandera pas si tu veux sauvegarder les modifications apportées au classeur.
'------------------------ Sub test() strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'Excel.exe'") For Each objProcess In colProcessList objProcess.Terminate Next
End Sub '------------------------
"MK" a écrit dans le message de news:
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Merci de votre aide.
MK
As-tu essayer ceci :
Attention, fermeture brutale... on ne te demandera pas si
tu veux sauvegarder les modifications apportées au classeur.
'------------------------
Sub test()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Excel.exe'")
For Each objProcess In colProcessList
objProcess.Terminate
Next
End Sub
'------------------------
"MK" <MK@discussions.microsoft.com> a écrit dans le message de news:
3DE7C180-1528-485F-8789-9093232B01C8@microsoft.com...
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en
cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt
Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Attention, fermeture brutale... on ne te demandera pas si tu veux sauvegarder les modifications apportées au classeur.
'------------------------ Sub test() strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'Excel.exe'") For Each objProcess In colProcessList objProcess.Terminate Next
End Sub '------------------------
"MK" a écrit dans le message de news:
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Merci de votre aide.
MK
lSteph
Re, ...un petit oubli dans le userfiorm_initialize (clear), et un petit ajout au bouton:
Dim svc As Object Dim myQuery As String Dim myp
Private Sub CommandButton1_Click() KillProcess ComboBox1 UserForm_Initialize End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process" ListBox1.Clear ComboBox1.Clear For Each myp In svc.execquery(myQuery) ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath ComboBox1.AddItem myp.Name Next Set svc = Nothing Exit Sub
UIniError: MsgBox "Error " & Err.Number & " (" & Err.Description & ")" Err.Clear End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process where name='" & ProcessName & "'" For Each myp In svc.execquery(myQuery) myp.Terminate Next Set svc = Nothing End Function ''''*********************
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Merci de votre aide.
MK
Re,
...un petit oubli dans le userfiorm_initialize (clear), et un petit
ajout au bouton:
Dim svc As Object
Dim myQuery As String
Dim myp
Private Sub CommandButton1_Click()
KillProcess ComboBox1
UserForm_Initialize
End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process"
ListBox1.Clear
ComboBox1.Clear
For Each myp In svc.execquery(myQuery)
ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath
ComboBox1.AddItem myp.Name
Next
Set svc = Nothing
Exit Sub
UIniError:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Err.Clear
End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process where name='" & ProcessName &
"'"
For Each myp In svc.execquery(myQuery)
myp.Terminate
Next
Set svc = Nothing
End Function
''''*********************
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en
cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt
Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.
Re, ...un petit oubli dans le userfiorm_initialize (clear), et un petit ajout au bouton:
Dim svc As Object Dim myQuery As String Dim myp
Private Sub CommandButton1_Click() KillProcess ComboBox1 UserForm_Initialize End Sub
Private Sub UserForm_Initialize()
On Error GoTo UIniError
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process" ListBox1.Clear ComboBox1.Clear For Each myp In svc.execquery(myQuery) ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath ComboBox1.AddItem myp.Name Next Set svc = Nothing Exit Sub
UIniError: MsgBox "Error " & Err.Number & " (" & Err.Description & ")" Err.Clear End Sub
Public Function KillProcess(ByVal ProcessName As String) As Boolean
Set svc = GetObject("winmgmts:rootcimv2") myQuery = "select * from win32_process where name='" & ProcessName & "'" For Each myp In svc.execquery(myQuery) myp.Terminate Next Set svc = Nothing End Function ''''*********************
Bonjour
J'aimerais savoir s'il est possible de fermer un processus avec Excel?
Dans Gestionnaires de Taches/ Processus il y a la liste de tous les .exe en cours et je voudrais fermer xxx.exe.
http://frederic.sigonneau.free.fr/code/Excel/FermerUneApplication.txt Cela ne fonctionne pas car l'application n'a pas visible avec Alt+Tab.