violent_ken
Messages postés1812Date d'inscriptionmardi 31 mai 2005StatutMembreDernière intervention26 octobre 2010
-
25 mars 2009 à 13:06
violent_ken
Messages postés1812Date d'inscriptionmardi 31 mai 2005StatutMembreDernière intervention26 octobre 2010
-
25 mars 2009 à 17:56
Salut !
Je cherche à pouvoir récupérer la liste des modules d'un processus via WMI.
En VB6, on peut faire comme cela :
Set files = objHost.wmiConnexion.ReferencesTo(process.Path_.path, "CIM_ProcessExecutable")
For Each itemFile In files
Set aFile = objHost.wmiConnexion.Get(itemFile.Antecedent)
Next
En VB.Net c'est complètement différente, on utile l'espace de nom Management :
Dim colProcesses As Management.ManagementObjectSearcher
Dim colObserver As New Management.ManagementOperationObserver
Dim refProcess As Management.ManagementObject
Dim con As New ConnectionOptions
con.Username = Nothing
con.Password = Nothing
con.Impersonation = ImpersonationLevel.Impersonate
colProcesses = New Management.ManagementObjectSearcher("SELECT * FROM Win32_Process")
colProcesses.Scope = New Management.ManagementScope("\" & Server & "\root\cimv2", con)
For Each refProcess In colProcesses.Get
Console.WriteLine(refProcess.GetPropertyValue("Name"))
Dim colModule As ManagementObjectCollection = refProcess.GetRelationships("CIM_ProcessExecutable")
For Each refModule As ManagementObject In colModule
Dim oo As Object = refModule.GetPropertyValue("Antecedent")
Console.WriteLine(oo)
Next
Next
Le seul problème c'est que GetPropertyValue("Antecedent"), même si çà renvoie bien le module, renvoie une string alors que moi j'ai besoin d'un ManagementObject (classe CIM_ProcessExecutable).
violent_ken
Messages postés1812Date d'inscriptionmardi 31 mai 2005StatutMembreDernière intervention26 octobre 20102 25 mars 2009 à 13:14
Salut !
Je cherche à pouvoir récupérer la liste des modules d'un processus via WMI.
En VB6, on peut faire comme cela :
Set files = objHost.wmiConnexion.ReferencesTo(process.Path_.path, "CIM_ProcessExecutable")
For Each itemFile In files
Set aFile = objHost.wmiConnexion.Get(itemFile.Antecedent)
Next
En VB.Net c'est complètement différente, on utile l'espace de nom Management :
Dim colProcesses As Management.ManagementObjectSearcher
Dim colObserver As New Management.ManagementOperationObserver
Dim refProcess As Management.ManagementObject
Dim con As New ConnectionOptions
con.Username = Nothing
con.Password = Nothing
con.Impersonation = ImpersonationLevel.Impersonate
colProcesses = New Management.ManagementObjectSearcher("SELECT * FROM Win32_Process")
colProcesses.Scope = New Management.ManagementScope("\" & Server & "\root\cimv2", con)
For Each refProcess In colProcesses.Get
Console.WriteLine(refProcess.GetPropertyValue("Name"))
Dim colModule As ManagementObjectCollection = refProcess.GetRelationships("CIM_ProcessExecutable")
For Each refModule As ManagementObject In colModule
Dim oo As Object = refModule.GetPropertyValue("Antecedent")
Console.WriteLine(oo)
Next
Next
Le seul problème c'est que GetPropertyValue("Antecedent"), même si çà renvoie bien le module, renvoie une string alors que moi j'ai besoin d'un ManagementObject (classe CIM_ProcessExecutable).
violent_ken
Messages postés1812Date d'inscriptionmardi 31 mai 2005StatutMembreDernière intervention26 octobre 20102 25 mars 2009 à 15:18
Salut,
malheureusement, si la classe Process permet de lister les processus des postes distants, elle n'offre aucune action dessus (kill impossible, liste des modules impossible...etc.)