|
FORUMS PROFESSIONNELS WINDEV, WEBDEV et WINDEV Mobile |
| | | | | |
| Récupérer les lignes de commande d'un processus (tâches windows) |
| Débuté par pb4807, 01 avr. 2015 10:18 - 4 réponses |
| |
| | | |
|
| |
| Posté le 01 avril 2015 - 10:18 |
| |
| |
| | | |
|
| | |
| |
| Posté le 02 avril 2015 - 16:07 |
Ce sera l'occasion de passer à WD20 si pas déjà fait 
http://doc.pcsoft.fr/fr-FR/?3035008
il y a une nouvelle option à ExeListeProcessus
eric l.
>Le 01/04/2015 08:18, Pierre BOUSQUET a écrit :
|
| |
| |
| | | |
|
| | |
| |
| Posté le 02 avril 2015 - 17:17 |
merci pour l'info ça me fera au moins une bonne raison pour l'acheter
eric l. a formulé la demande :
Ce sera l'occasion de passer à WD20 si pas déjà fait http://doc.pcsoft.fr/fr-FR/?3035008il y a une nouvelle option à ExeListeProcessus eric l. >Le 01/04/2015 08:18, Pierre BOUSQUET a écrit : |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 5 messages |
|
| Posté le 24 juillet 2015 - 17:01 |
Bonjour,
Pour ceux qui cherchent, même avec ExeListeProcessus en Windev 20 il n'est pas possible d'avoir la ligne de commande si l'on est un processus 32 bits dans un environnement 64 bits. On peut le faire avec les APIs mais ça plante une fois sur 20 environ, c'est assez lent et ça génère des blocages (avec les APIs Kernel32.OpenProcess, psapi.EnumProcessModules et Kernel32.QueryFullProcessImageNameA)
J'ai trouvé une autre méthode, et voici donc le code de la fonction que j'ai créée.
Bons dév à tous !
Fabrice, Toulouse
// Déclaration du type exeTypeInformation exeTypeInformation est une Enumération exeRien exeLigneCommande exeNomExecutable exeCheminCompletExécutable exeParentPID exePID FIN
// Fonction de récupération des processus en cours PROCEDURE ListeDesProcessus(iexeTypeInformation1 est un exeTypeInformation ... ,iexeTypeInformation2 est un exeTypeInformation = exeRien ... ,iexeTypeInformation3 est un exeTypeInformation = exeRien ... ,iexeTypeInformation4 est un exeTypeInformation = exeRien ... ,iexeTypeInformation5 est un exeTypeInformation = exeRien ... ) sParam est une chaîne sParamAAjouter est une chaîne sResultat est une chaîne
//exeLigneCommande //exeNomCourt //exeNomLong //exeParentPID //exePID
//objProcess.ProcessId & vbTab & _ //objProcess.ParentProcessId & vbTab & _ //objProcess.CommandLine & vbTab & _ //objProcess.Caption & vbTab & _ //objProcess.ExecutablePath & vbNewLine POUR i = 1 _A_ 5 sParamAAjouter = "" SELON {"iexeTypeInformation" + i, indVariable} CAS exeLigneCommande sParamAAjouter += "objProcess.CommandLine" CAS exeNomExecutable sParamAAjouter += "objProcess.Caption" CAS exeCheminCompletExécutable sParamAAjouter += "objProcess.ExecutablePath" CAS exeParentPID sParamAAjouter += "objProcess.ParentProcessId" CAS exePID sParamAAjouter += "objProcess.ProcessId" AUTRE CAS FIN SI sParamAAjouter <> "" ALORS SI i >= 2 ALORS sParam += " & vbTab & " FIN sParam += sParamAAjouter FIN FIN sParam += " & vbNewLine" + RC
oScript est un objet Automation "MSScriptControl.ScriptControl" sScriptVBS est une chaîne = [ Function ListeDesProcessus() Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & "." & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery( _ "Select * from Win32_Process " _ & "Where Name != 'WScript.exe'", , 48) Dim strReport For Each objProcess in colProcesses ' skip current script, and display the rest strReport = strReport & _ %1 Next ListeDesProcessus = strReport End Function ] sScriptVBS = ChaîneConstruit(sScriptVBS, sParam)
oScript>>Language("VBScript") oScript>>Reset() oScript>>AddCode(sScriptVBS) oScript>>Timeout(-1) sResultat = oScript>>Run("ListeDesProcessus") RENVOYER(sResultat) |
| |
| |
| | | |
|
| | |
| |
| Posté le 25 mars 2026 - 10:57 |
a écrit :
Bonjour,
Pour ceux qui cherchent, même avec ExeListeProcessus en Windev 20 il n'est pas possible d'avoir la ligne de commande si l'on est un processus 32 bits dans un environnement 64 bits. On peut le faire avec les APIs mais ça plante une fois sur 20 environ, c'est assez lent et ça génère des blocages (avec les APIs Kernel32.OpenProcess, psapi.EnumProcessModules et Kernel32.QueryFullProcessImageNameA)
J'ai trouvé une autre méthode, et voici donc le code de la fonction que j'ai créée.
Bons dév à tous !
Fabrice, Toulouse
// Déclaration du type exeTypeInformation exeTypeInformation est une Enumération exeRien exeLigneCommande exeNomExecutable exeCheminCompletExécutable exeParentPID exePID FIN
// Fonction de récupération des processus en cours PROCEDURE ListeDesProcessus(iexeTypeInformation1 est un exeTypeInformation ... ,iexeTypeInformation2 est un exeTypeInformation = exeRien ... ,iexeTypeInformation3 est un exeTypeInformation = exeRien ... ,iexeTypeInformation4 est un exeTypeInformation = exeRien ... ,iexeTypeInformation5 est un exeTypeInformation = exeRien ... ) sParam est une chaîne sParamAAjouter est une chaîne sResultat est une chaîne
//exeLigneCommande //exeNomCourt //exeNomLong //exeParentPID //exePID
//objProcess.ProcessId & vbTab & _ //objProcess.ParentProcessId & vbTab & _ //objProcess.CommandLine & vbTab & _ //objProcess.Caption & vbTab & _ //objProcess.ExecutablePath & vbNewLine POUR i = 1 _A_ 5 sParamAAjouter = "" SELON {"iexeTypeInformation" + i, indVariable} CAS exeLigneCommande sParamAAjouter += "objProcess.CommandLine" CAS exeNomExecutable sParamAAjouter += "objProcess.Caption" CAS exeCheminCompletExécutable sParamAAjouter += "objProcess.ExecutablePath" CAS exeParentPID sParamAAjouter += "objProcess.ParentProcessId" CAS exePID sParamAAjouter += "objProcess.ProcessId" AUTRE CAS FIN SI sParamAAjouter <> "" ALORS SI i >= 2 ALORS sParam += " & vbTab & " FIN sParam += sParamAAjouter FIN FIN sParam += " & vbNewLine" + RC
oScript est un objet Automation "MSScriptControl.ScriptControl" sScriptVBS est une chaîne = [ Function ListeDesProcessus() Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & "." & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery( _ "Select * from Win32_Process " _ & "Where Name != 'WScript.exe'", , 48) Dim strReport For Each objProcess in colProcesses ' skip current script, and display the rest strReport = strReport & _ %1 Next ListeDesProcessus = strReport End Function ] sScriptVBS = ChaîneConstruit(sScriptVBS, sParam)
oScript>>Language("VBScript") oScript>>Reset() oScript>>AddCode(sScriptVBS) oScript>>Timeout(-1) sResultat = oScript>>Run("ListeDesProcessus") RENVOYER(sResultat)
ça marche parfaitement. Génial ! |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|