OVH Cloud OVH Cloud

Stopper un programme a partir d'access

3 réponses
Avatar
Rey
Bonjour à tous,
Quelqu'un sait-il comment stopper un programme depuis acces, par exemple
fermer iexplorer qui serait ouvert ? L'inverse de SHELL en d'autres termes.
Merci.

3 réponses

Avatar
RaphK34
Bonjour,
il me semble que tu peux "tuer" une tache avec la commande KILL, mais ce
n'est pas très propre ;)


--
@+ Raph.

--------------------------------------------
Merci de répondre sur le NG
Toutes remarques bienvenues !

Pour un contact direct, utiliser:
en enlevant nospam.
--------------------------------------------



"Rey" a écrit dans le message de news:
4222e75e$0$11704$
| Bonjour à tous,
| Quelqu'un sait-il comment stopper un programme depuis acces, par exemple
| fermer iexplorer qui serait ouvert ? L'inverse de SHELL en d'autres
termes.
| Merci.
|
|
Avatar
Codial
Bonjour,

Attention, sauf erreur de ma part l'instruction KILL supprime des fichiers
d'un disque sans passer par la poubelle!!!!

Codial


"RaphK34" a écrit dans le message de news:

Bonjour,
il me semble que tu peux "tuer" une tache avec la commande KILL, mais ce
n'est pas très propre ;)


--
@+ Raph.

--------------------------------------------
Merci de répondre sur le NG
Toutes remarques bienvenues !

Pour un contact direct, utiliser:
en enlevant nospam.
--------------------------------------------



"Rey" a écrit dans le message de news:
4222e75e$0$11704$
| Bonjour à tous,
| Quelqu'un sait-il comment stopper un programme depuis acces, par exemple
| fermer iexplorer qui serait ouvert ? L'inverse de SHELL en d'autres
termes.
| Merci.
|
|




Avatar
MB
Bonjour,
Tuer un processus.
Mettre le code dans un module si celà peut t'aider:
'------------------------------------------------------
Option Compare Database
Option Explicit
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
'---voir WINAPI32.TXT
Public Function FN_CREER_PROCESS(PROC As String, NOM_COMPUTER As String)
'---ouvrir (créer) un process
On Error GoTo err_FN_CREER_PROCESS
Dim process As WbemScripting.SWbemObject
Dim x As String, Y As String

Dim processid As Long
Dim result As Long
'NOM_COMPUTER = FN_GetComputerName
FN_CREER_PROCESS = False
Y = "winmgmts:{impersonationlevel=impersonate}!" & NOM_COMPUTER &
"rootcimv2:win32_process"

Set process = GetObject(Y)

x = PROC

result = process.create(x, Null, Null, processid)
If processid = -1 Then Exit Function
'MsgBox "Chemin process:" & process.Path_
FN_CREER_PROCESS = True
Exit Function
err_FN_CREER_PROCESS:
MsgBox Err & " " & Error
Exit Function

End Function
Public Function FN_SUP_PROCESS_H(HW As Long, NOM_COMPUTER As String)
'---terminer (supprimer) un process
On Error GoTo err_FN_SUP_PROCESS_H
Dim CURRENT_PID As Long
Dim objs As WbemScripting.SWbemObjectSet
Dim obj As WbemScripting.SWbemObject
Dim x As String, Y As String
x = PROC
FN_SUP_PROCESS_H = False
CURRENT_PID = GetCurrentProcessId()

Y = "winmgmts:" & NOM_COMPUTER & ""
Set objs = GetObject(Y).ExecQuery("select * from win32_process where
handle=" & HW)
'---ne pas tuer, éventuellement son processus courant
For Each obj In objs
'Debug.Print obj.Terminate
obj.Terminate
FN_SUP_PROCESS_H = True
Next obj


Exit Function
err_FN_SUP_PROCESS_H:
MsgBox Err & " " & Error
Exit Function

End Function
Public Function FN_SUP_PROCESS(PROC As String, NOM_COMPUTER As String)
'---terminer (supprimer) un process
On Error GoTo err_FN_SUP_PROCESS
Dim CURRENT_PID As Long
Dim objs As WbemScripting.SWbemObjectSet
Dim obj As WbemScripting.SWbemObject
Dim x As String, Y As String
x = PROC
FN_SUP_PROCESS = False

'Set objs = GetObject("winmgmts:mbp").ExecQuery("select * from
win32_process where name='notepad.exe'")
Y = "winmgmts:" & NOM_COMPUTER & ""
Set objs = GetObject(Y).ExecQuery("select * from win32_process where
name=""" & x & """")
CURRENT_PID = GetCurrentProcessId()
For Each obj In objs
'Debug.Print obj.Terminate
If obj.processid <> CURRENT_PID Then FN_SUP_PROCESS = True: obj.Terminate
'---sauf le processus courant

Next obj

Exit Function
err_FN_SUP_PROCESS:
MsgBox Err & " " & Error
Exit Function

End Function
Public Function FN_LIS_PROCESS(c As Control, NOM_COMPUTER As String)
'---lister les process tournant sur un computer
'C=contrôle (liste ou sous-formulair) pour rafraîchir
' créer une table pour stocker les processus (USYS_PROCESS)
'proc_no entier long
'proc_name txt
'proc_CommandLine txt
'proc_computer txt
'PROC_ID entier long
'proc_classe txt
'proc_osname txt

On Error GoTo err_FN_SUP_PROCESS
Dim SQL, MONJEU As Recordset, NO
Dim P As Long
Dim objs As WbemScripting.SWbemObjectSet
Dim obj As WbemScripting.SWbemObject
Dim x As String, Y As String
x = PROC


Y = "winmgmts:" & NOM_COMPUTER & ""
Set objs = GetObject(Y).ExecQuery("select * from win32_process ")
SQL = "delete * from USYS_PROCESS;"
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True
c.Requery
Set MONJEU = DBEngine(0)(0).OpenRecordset("USYS_PROCESS")
NO = 1

With MONJEU
For Each obj In objs
'MsgBox obj.Path_
'MsgBox "nom:" & obj.GetObjectText_ '---pour voir toutes les propriétés
.AddNew
!proc_no = NO
!proc_name = obj.DESCRIPTION
!proc_CommandLine = obj.CommandLine
!proc_computer = obj.CSName
!PROC_ID = obj.processid
!proc_classe = obj.CreationClassName
!proc_osname = obj.OSName
.Update
NO = NO + 1

Next obj
.Close
End With
c.Requery
Exit Function
err_FN_SUP_PROCESS:
DoCmd.SetWarnings True
If Err = 3163 Then Resume Next
MsgBox "Liste process:" & Err.Number & " " & Err.DESCRIPTION
Exit Function

End Function
'---------------------------------------------
"Rey" a écrit dans le message de news:
4222e75e$0$11704$
Bonjour à tous,
Quelqu'un sait-il comment stopper un programme depuis acces, par exemple
fermer iexplorer qui serait ouvert ? L'inverse de SHELL en d'autres
termes.

Merci.