Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Kill a process
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Divers
Thread ID:
00890217
Message ID:
00890501
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>I have the need of killing a process, fron within Visual foxpro. actually I am calling the TaskKill utility of XP, now I need to run it from Win2K, how can I kill a process in Win2K?

If you know the ProcessID #, You can try:
loCIMV2		= GetObject("winmgmts://localhost/root/cimv2")
loProcesses	= loCimv2.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = 2756")
For Each objProcess in loProcesses
	objProcess.Terminate(0)
Next
Or, if you want to kill all instances of an exe, you can try:
loCIMV2		= GetObject("winmgmts://localhost/root/cimv2")
loProcesses	= loCimv2.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'AcroRd32.exe'")
For Each objProcess in loProcesses
	objProcess.Terminate(0)
Next
I think this should work for both XP and 2000, although I do not have 2000 to test, additionally with little modification you can kill remote processes.

hTh
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform