Récupérer le taux d'utilisation CPU et mémoire en VBScript

Résolu
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006 - 15 juin 2006 à 09:47
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006 - 18 juin 2006 à 15:34
Bonjour, je souhaiterais récupérer le taux d'utilisation de la mémoire
et du CPU de ma machine locale. Existe-t-il une commande, pour
récupérer ces infos ?

Merci d'avance.

8 réponses

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
15 juin 2006 à 17:33
 Bonjour ,

Avec WMI:

l'affichage du résultat dans la msgbox (echo) n'est pas terrible, mais
que d'informations:
 
dim strComputer,objWMIService,colProcesses,objProcess,ProcessTime,strCreationDate,user,Domain,strOwner,h,m,s,chaine
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process")        ' where Name='IEXPLORE.EXE'
Chaine="Process     |Creation Date Time |Handles|Threads|Owner              |Priority|MemoryUsage|MaxMemUsage|MemRequired|MaxMemRequi|       Swap|   Max Swap|CPU time|PID |PFaults|Path" & vbCrLf
For Each objProcess in colProcesses
        If objProcess.GetOwner ( User, Domain ) = 0 Then
                strOwner= Domain & "" & User
        Else
                strOwner="Unknown"
        End If
        ProcessTime=(CSng(objProcess.KernelModeTime) + CSng(objProcess.UserModeTime)) / 10000000
        h=right("0" & fix(ProcessTime/60/60),2)
        ProcessTime=ProcessTime-h*60*60
        m=right("0" & fix(ProcessTime/60),2)
        s=Right("0" & round(ProcessTime-m*60),2)
        strCreationDate=Mid(objProcess.CreationDate,7,2) & "/" & Mid(objProcess.CreationDate,5,2) & "/" & Left(objProcess.CreationDate,4) & " " & Mid(objProcess.CreationDate,9,2) & ":" & Mid(objProcess.CreationDate,11,2) & ":" & Mid(objProcess.CreationDate,13,2)
        If strCreationDate="// ::" Then strCreationDate=Space(19)
        Chaine=Chaine &  Left(objProcess.Name & space(8),12) & "|" _
                & strCreationDate & "|" & Right(Space(6) & objProcess.HandleCount,7) & "|" _
                & Right(Space(6) & objProcess.ThreadCount,7) & "|" _
                & Left(strOwner & space(14),19) & "|" _
                & Left(objProcess.Priority & Space(7),8) & "|" _
                & Right(Space(10) & objProcess.PageFileUsage ,11) & "|" _
                & Right(Space(10) & objProcess.PeakPageFileUsage ,11) & "|" _
                & Right(Space(8) & objProcess.WorkingSetSize ,11) & "|" _
                & Right(Space(8) & objProcess.PeakWorkingSetSize ,11) & "|" _
                & Right(Space(10) & objProcess.VirtualSize ,11) & "|" _
                & Right(Space(10) & objProcess.PeakVirtualSize ,11) & "|" _
                & h & ":" & m & ":" & s & "|" _
                & Left(objProcess.ProcessID & space(3),4) & "|"  _
                & Right(Space(6) & objProcess.PageFaults ,7) & "|" & objProcess.ExecutablePath
        Chaine=Chaine & vbCrLf
Next
Set .... = Nothing
wscript.echo chaine

jean-marc
3
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006
16 juin 2006 à 09:13
JMO, merci beaucoup pour ta réponse. L'affichage
n'est pas un problème, car ces données (enfin une partie d'entre elles)
vont aller compléter un fichier excel. Par contre, j'ai juste une
dernière question : J'aurais aimé récupérer le pourcentage
d'utilisation du CPU par application. Sais-tu comment je dois m'y
prendre ? Eventuellement, est-ce possible avec une opération
arithmétique simple, à partir des données que j'obtiens grâce à ton
code ? Désolé pour la naïveté de ma question, je ne suis pas encore un
pro du VBScript. Et encore merci.
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
16 juin 2006 à 12:31
 Bonjour,

Je n'ai pas d'exemple écrit.
En mettant le résultat dans un tableau + un algo qui parcoure ce tableau.
Du style, if process(i) =  processes(i) Then cpu_process(i) = cpu_process(i) + process(i) (c'est pas très clair !!!!).

jean-marc

Il doit y avoir des exemples de tableau(x) en vb6 sur le forum (recherche tableau...)
ou sur http://www.codyx.org/
Pour ma part, je cherche en vb6, puis je retranscrit le script en vbs.
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
16 juin 2006 à 12:59
 Re-bonjour,

J'ai trouvé ce script ci-dessous, mais, je n'arrive pas à le faire fonctionner.

' --------------------------------------------------------------------
' Script d'affichage détaillé des processus en cours
' sur une machine locale ou distante
' Fait appel à Internet Explorer pour la saisie
' des paramètres et l'affichage des résultats
'
' Jean-Claude BELLAMY © 2002
' --------------------------------------------------------------------
Dim args, network, computer, fso, ts, tparam, tPrint, oIE, fExec, user,domain, system,process
Set network  = Wscript.CreateObject("WScript.Network")
Set Shell = WScript.CreateObject("WScript.Shell")
' Création du fichier HTML qui va servir de formulaire
fichtml=GetPath() & "processlist.html"
ficparam=GetPath() & "processlist.cfg"
ficprint=GetPath() & "processlist.txt"



local=lcase(network.ComputerName)
Set args=Wscript.Arguments
If args.count>0 Then
 computer=lcase(args(0))
Else
 computer=local 
 End If
If computer=local Then typeordi="local" else typeordi="distant"
RootTitle="Liste des processus sur " & computer & " (" & typeordi & ")"
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set ts  = fso.CreateTextFile(fichtml, True)
isparam=false
If fso.FileExists(ficparam)  Then
 Set tparam=fso.OpenTextFile(ficparam)
 isparam=true
 End If'Choix des paramètres
WriteHTMLHeader
header="Paramètres à afficher dans "
header=header & "IE"
' test d'existence de Excel
On Error Resume Next
ReadKey=shell.RegRead("HKEY_CLASSES_ROOT\.xls")
If Err.Number=0 Then header=header & "Excel"
On error goto 0
header=header & "Bloc-notes"
ts.writeline " " & header & "   : "
ts.writeline "\"
objet =\"Win32_Process\"
Set System = GetObject(\"winmgmts:\" & objet)
n=0
ncol=3
dim prop()
for each Property in System.Properties_
 AddProp Property.Name
 next
' Ajout des méthodes GetOwner et GetOwnerSid\"
AddProp \"GetOwner\"
AddProp \"GetOwnerSid\"
r=ncol-(n mod ncol)
If r<>ncol Then
 For i = 1 To r
  ts.writeline \", \"
  Next
 ts.writeline \"\"
 end if
ts.writeline "
"
WriteHTMLBottom "Afficher","Fermer"



If isParam Then tParam.Close
RunIE 600,600,true



DisplayIE=false
DisplayExcel=false
DisplayNotepad=false
if oIE.Document.processlistForm.IE.Checked then DisplayIE=true
if oIE.Document.processlistForm.Excel.Checked then DisplayExcel=true
if oIE.Document.processlistForm.Notepad.Checked then DisplayNotepad=true



Set tParam = fso.CreateTextFile(ficparam, True)
' Utilisation de la fonction execute afin de créer dynamiquement
' des commandes faisant intervenir des noms de champs variables
dim f(), res()
redim f(n), res(n)
lmax=0
for i = 0 to n-1
 f(i) = "function testparam() " & vbcrlf
 f(i) = f(i) & "testparam=0" & vbcrlf
 f(i) = f(i) & "if oIE.Document.processlistForm.param" & i &".Checked then testparam=1" & vbcrlf
 f(i) = f(i) & "end function" & vbcrlf
 execute f(i)
 res(i)=testparam()
 state=""
 If res(i)=1 Then
  state="Checked"
  l=len(prop(i))
  If lmax<l then lmax=l
  end if
 tParam.writeline state
 next
oIE.Quit
tParam.close



'Affichage des résultats
Set ts  = fso.CreateTextFile(fichtml, True)
If DisplayExcel Then
 Dim objXL
 Set objXL = WScript.CreateObject("Excel.Application")
 objXL.Workbooks.Add
 objXL.Cells(1,1).Value = Titre
 objXL.Visible = True
 End If



If DisplayNotepad Then
 Set tPrint = fso.CreateTextFile(ficprint, True)
 tprint.writeline Titre
 tprint.WriteBlankLines(1)
 end if
WriteHTMLHeader
ts.writeline "Liste des processus (" & date & " " & time & ")
"
ts.writeline "\"
ts.writeline \"----
\"
first=true
nl=2
nc=0
ts.writeline \"Terminer, \"
For i= 0 To n-1
 If res(i)=1 Then
  If DisplayNotepad then
   If not first Then tprint.write chr(9) else first=false
   tprint.write prop(i)
   end if
  nc=nc+1
  If DisplayExcel Then objXL.Cells(nl,nc).Value = prop(i)
  comment=\"\"
  If lcase(prop(i))=\"executablepath\" Then
   comment=\"
Cliquer sur un lien pour afficher
le fichier dans l'explorateur\"
   end if
  ts.writeline \"" & prop(i) & comment & ", \"
  End If
 Next
ts.writeline \"\"
If DisplayNotepad Then tprint.WriteBlankLines(2)

Set System=GetObject (\"winmgmts:{impersonationLevel=impersonate}!//\" & Computer).InstancesOf(objet)
nl=2
nc=0
nproc=0
dim ProcState(),ProcNum()
for each Process in System
 nl=nl+1
 first=true
 SetKill Process.Handle
 ts.writeline \"----
\"
 ts.writeline \", \"
 nc=0
 For i= 0 To n-3
  If res(i)=1 Then
   var =\"Process.\" & prop(i)
   valeur=eval(var)
   If IsNull(valeur) Then valeur=\"\"
   link=\"\"
   If prop(i)=\"ExecutablePath\" and valeur<>\"\" Then
    filename=valeur
    If computer<>local Then filename=\"\\\" & computer & \"\\" & Replace(filename, \":\", \"$\")
    link=\"\"
    End If
   addProcess 0,valeur,link
   End If
  Next
 If res(n-2)=1 Then
  result=Process.GetOwner(user,domain)
  addProcess result, user & \"/\" & domain,\"\"
  end if
 If res(n-1)=1 Then
  result=Process.GetOwnerSid(SID)
  addProcess result, SID,\"\"
  end if
 ts.writeline \"\"
 If DisplayNotepad Then tprint.writeline \"\"
 next

If DisplayExcel Then
 objXL.Rows(\"2:2\").Select
 objXL.Selection.Font.Bold = True
 d1=int((nc-1)/26)
 d2=((nc-1) mod 26)
 If d1=0 Then l1max=\"\" else l1max=chr(Asc(\"A\")+d1-1)
 l2max=chr(Asc(\"A\")+d2)
 objXL.Columns(\"A:\" & l1max & l2max).Select
 objXL.Selection.Columns.AutoFit
 objXL.Rows(\"1:1\").Select
 objXL.Selection.Font.Bold = True
 objXL.Selection.Font.Size = 12
 end if

ts.writeline "
"



If DisplayNotepad Then
 tprint.close
 commande=shell.ExpandEnvironmentStrings("%windir%\notepad.exe " & chr(34) & ficprint & chr(34))
 shell.Run commande, 1
 end if



If DisplayIE Then
 WriteHTMLBottom "","Fermer"
 RunIE 600,400,false
 End If
 
Wscript.quit



'------------------------------------------------------------
Function FormatStr(ch,lmax)
l=len(ch)
If l<lmax Then
 For k = l+1 To lmax
  ch=ch & " "
  Next
 End If
FormatStr=ch
End Function
'------------------------------------------------------------
' Fonction de récupération du répertoire courant
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, ""))
End Function
'------------------------------------------------------------
Sub WriteHTMLHeader
ts.writeline "<html>"
ts.writeline "<head>"
ts.writeline "<title>" & Titre & "</title>"
ts.writeline "<STYLE TYPE=""text/css"">"
ts.writeline " body {"
ts.writeline " font-family: Verdana;"
ts.writeline " font-size: 8 pt }"
ts.writeline " h1, h2, h3, h4, h5, h6 { font-family: Verdana }"
ts.writeline "table {"
ts.writeline " table-border-color-light: rgb(102,204,204);"
ts.writeline " table-border-color-dark:  rgb(0,102,102);"
ts.writeline " font-size: 8 pt;"
ts.writeline " font-family: Verdana }"
ts.writeline "</STYLE>"
ts.writeline "</head>"
ts.writeline ""
ts.writeline "<script language=""VBScript""> "
ts.writeline "<!--"
ts.writeline "Dim ready,flagfile,file,flagkill,ID"
ts.writeline "Sub B0_OnClick"
ts.writeline "ready=-1"
ts.writeline "End Sub"
ts.writeline "Sub B1_OnClick"
ts.writeline "ready=1"
ts.writeline "End Sub"



ts.writeline "Sub Window_OnLoad()"
ts.writeline "ready=0"
ts.writeline "flagfile=0"
ts.writeline "flagkill=0"
ts.writeline "file="""""
ts.writeline "ID=0"
ts.writeline "End Sub"



ts.writeline "Public Function CheckVal()"
ts.writeline "CheckVal=ready"
ts.writeline "End function"



ts.writeline "Public Function CheckFile()"
ts.writeline "CheckFile=flagfile"
ts.writeline "End function"



ts.writeline "Public Function CheckID()"
ts.writeline "CheckID=flagkill"
ts.writeline "End function"



ts.writeline "Public Sub ResetFile()"
ts.writeline "flagFile=0"
ts.writeline "End sub"



ts.writeline "Public Sub ResetID()"
ts.writeline "flagkill=0"
ts.writeline "End sub"



ts.writeline "Public Function GetFile()"
ts.writeline "GetFile=file"
ts.writeline "End function"



ts.writeline "Public Function GetID()"
ts.writeline "GetID=ID"
ts.writeline "End function"



ts.writeline "function Explore(filename)"
ts.writeline "flagfile=1"
ts.writeline "file=filename"
ts.writeline "End function"



ts.writeline "function Kill(handle)"
ts.writeline "flagkill=1"
ts.writeline "ID=handle"
ts.writeline "End function"



ts.writeline "'-->"
ts.writeline "</script>"
ts.writeline "<form name=""processlistForm"">"
ts.writeline "<center>Ordinateur " & typeordi & " " & Computer & "</center>
<hr>"
End Sub
' -------------------------------------
Sub WriteHTMLBottom(B1,B0)
ts.writeline "
"
If B1<>"" Then ts.writeline ""
If B0<>"" Then ts.writeline ""
ts.writeline "</form>"
ts.writeline ""
ts.writeline "</html>"
ts.Close
End Sub
' -------------------------------------
Sub RunIE(W,H,testclose)
' Ouverture d'Internet Explorer
Set oIE = WScript.CreateObject("InternetExplorer.Application", "IE_")
oIE.Left = 50       
oIE.Top = 100
oIE.Height = H
oIE.Width = W
oIE.MenuBar = 0        
oIE.ToolBar = 0
oIE.StatusBar = 1
oIE.navigate fichtml 
oIE.Visible = 2     
Do While (oIE.Busy)   
 WScript.Sleep 200 
 Loop
shell.AppActivate Titre



' Attente d'action sur le bouton ou fermeture de la fenêtre
On Error Resume Next
Do                  
 WScript.Sleep 100
 If oIE.Document.Script.CheckFile()<>0 Then
  path=oIE.Document.Script.GetFile()
  oIE.Document.Script.ResetFile
  If path<>"" Then Shell.run "explorer /select," & path,1
  End If
 If oIE.Document.Script.CheckID()<>0 Then
  ID=oIE.Document.Script.GetID()
  oIE.Document.Script.ResetID
  If ID<>0 Then
   If GetStateKill(ID)=0 Then
    MsgBox "Le processus " & ID & " n'existe plus", vbExclamation,"Terminaison de processus"
   Else
    rep=MsgBox("Etes-vous sûr de terminer le processus " & ID & "?", vbYesNo + vbQuestion,"Terminaison de processus")
    If rep=vbYes Then
     result=killprocess(ID)
     If result=0 Then CancelKill(ID)
     end if
    End If
   end if
  End If
 Loop While (oIE.Document.Script.CheckVal() = 0)
' Si on ferme directement IE sans passer par un bouton,
' cela provoque une erreur qui est détectée et alors
' on quitte le script
If Err <> 0 Then
 If testclose Then
  Wscript.quit
 else
  On Error goto 0
  exit sub
  end if
 end if
test=oIE.Document.Script.CheckVal()
If test=-1 Then
 oIE.Quit
 If testclose Then Wscript.quit
 end if
On Error goto 0
End Sub
' -------------------------------------
Sub AddProp(ch)
n=n+1
redim preserve prop(n)
prop(n-1)=ch
state=""
If isParam then If not tParam.AtEndOfStream Then state=tParam.ReadLine
If ((n-1) mod ncol)=0 Then ts.writeline "<tr>"
ts.writeline "<td>" & prop(n-1) & "</td>"
If (n mod ncol)=0 Then ts.writeline "</tr>"
End Sub
' -------------------------------------
Sub AddProcess(result,ch, chlink)
tag=""
If IsNumeric(ch) Then tag=" align=""right"""
ts.writeline "<td" & tag & ">"
If result=0 Then
 If chlink<>"" Then ts.writeline chlink
 ts.writeline ch
 If chlink<>"" Then ts.writeline ""
 end if
ts.writeline "</td>"
If DisplayNotepad Then
 If not first Then tprint.write chr(9) else first=false
 If result=0 Then tprint.write ch 
 end if
nc=nc+1 
If DisplayExcel and result=0 Then objXL.Cells(nl,nc).Value = ch
End Sub
' -------------------------------------
Function Titre
Titre=rootTitle & " " & Date & " " & Time
End Function
' -------------------------------------
Function KillProcess(ID)
Set System=GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery("select * from " _
& objet & " where Handle=" & ID)
result=-1
for each Process in System
 result=Process.terminate(0)
 If result<>0 Then
  MsgBox "Erreur code " & result, vbExclamation,"Terminaison processus " & ID
 Else
  MsgBox "Processus correctement terminé", vbInformation,"Terminaison processus " & ID
  End If
 next
KillProcess=result
End Function
' -------------------------------------
Sub SetKill(Handle)
nproc=nproc+1
redim preserve ProcNum(nproc),ProcState(nproc)
ProcNum(nproc-1)=handle
ProcState(nproc)=1
End Sub
' -------------------------------------
Function GetStateKill(ID)
GetStateKill=0
For i = 0 To nproc-1
 If ProcNum(i)=ID Then
  GetStateKill=ProcState(i)
  exit function
  End If
 Next
End Function
' -------------------------------------
Sub CancelKill(ID)
For i = 0 To nproc-1
 If ProcNum(i)=ID Then
  ProcState(i)=0
  exit sub
  End If
 Next
End Sub
' -------------------------------------



Donc, si quelqu'un lit ce topic et a solutionné ce script, je suis interessé par la solution.
jean-marc
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006
16 juin 2006 à 15:41
Re-salut Jean-Marc,


Merci pour ta réponse. Je ne me suis peut-être pas exprimé clairement.
En faite, je voudrais récupérer le % d'utilisation du CPU, avec la même
présentation que dans le task manager. Je suppose qu'il suffit de faire
une opération simple à partir des données que ton script fournit, mais
aucune idée de cette opération... Comme c'est un temps d'utilisation du
CPU, il doit falloir le diviser par un autre temps pour que ça soit
homogène, mais je ne sais absolument pas à quel autre temps je dois le
comparer...


Ton script, on dirait qu'il remplit les mêmes fonctions que le task
manager. Je vais y jeter un coup d'oeil, mais vu mes connaissances
limitées, je ne pense pas réussir à le faire fonctionner si toi tu n'as
pas réussi... Enfin ça me permettra peut-être de m'améliorer !


Merci encore pour ton aide !
0
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006
16 juin 2006 à 17:06
Re !!! en faite il faut utiliser win32_processor au lieu de
win32_process. J'ai trouvé ce code qui donne toutes les données sur la
classe :


On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)

For Each objItem in colItems

mess= mess & "AddressWidth: " & objItem.AddressWidth & vbCrLf

mess= mess & "Architecture: " & objItem.Architecture & vbCrLf

mess= mess & "Availability: " & objItem.Availability & vbCrLf

mess= mess & "Caption: " & objItem.Caption & vbCrLf

mess= mess & "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode & vbCrLf

mess= mess & "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig & vbCrLf

mess= mess & "CpuStatus: " & objItem.CpuStatus & vbCrLf

mess= mess & "CreationClassName: " & objItem.CreationClassName & vbCrLf

mess= mess & "CurrentClockSpeed: " & objItem.CurrentClockSpeed & vbCrLf

mess= mess & "CurrentVoltage: " & objItem.CurrentVoltage & vbCrLf

mess= mess & "DataWidth: " & objItem.DataWidth & vbCrLf

mess= mess & "Description: " & objItem.Description & vbCrLf

mess= mess & "DeviceID: " & objItem.DeviceID & vbCrLf

mess= mess & "ErrorCleared: " & objItem.ErrorCleared & vbCrLf

mess= mess & "ErrorDescription: " & objItem.ErrorDescription & vbCrLf

mess= mess & "ExtClock: " & objItem.ExtClock & vbCrLf

mess= mess & "Family: " & objItem.Family & vbCrLf

mess= mess & "InstallDate: " & objItem.InstallDate & vbCrLf

mess= mess & "L2CacheSize: " & objItem.L2CacheSize & vbCrLf

mess= mess & "L2CacheSpeed: " & objItem.L2CacheSpeed & vbCrLf

mess= mess & "LastErrorCode: " & objItem.LastErrorCode & vbCrLf

mess= mess & "Level: " & objItem.Level & vbCrLf

mess= mess & "LoadPercentage: " & objItem.LoadPercentage & vbCrLf

mess= mess & "Manufacturer: " & objItem.Manufacturer & vbCrLf

mess= mess & "MaxClockSpeed: " & objItem.MaxClockSpeed & vbCrLf

mess= mess & "Name: " & objItem.Name & vbCrLf

mess= mess & "OtherFamilyDescription: " & objItem.OtherFamilyDescription & vbCrLf

mess= mess & "PNPDeviceID: " & objItem.PNPDeviceID & vbCrLf

mess= mess & "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities & vbCrLf

mess= mess & "PowerManagementSupported: " & objItem.PowerManagementSupported & vbCrLf

mess= mess & "ProcessorId: " & objItem.ProcessorId & vbCrLf

mess= mess & "ProcessorType: " & objItem.ProcessorType & vbCrLf

mess= mess & "Revision: " & objItem.Revision & vbCrLf

mess= mess & "SocketDesignation: " & objItem.SocketDesignation & vbCrLf

mess= mess & "Status: " & objItem.Status & vbCrLf

mess= mess & "StatusInfo: " & objItem.StatusInfo & vbCrLf

mess= mess & "Stepping: " & objItem.Stepping & vbCrLf

mess= mess & "SystemCreationClassName: " & objItem.SystemCreationClassName & vbCrLf

mess= mess & "SystemName: " & objItem.SystemName & vbCrLf

mess= mess & "UniqueId: " & objItem.UniqueId & vbCrLf

Next

msgbox mess

La seule chose qui m'étonne, c'est qu'au niveau de la charge cpu,
c'est toujours soit 0, soit 100... faudrait que je trouve une appli qui
me charge mon cpu à une valeur intermédiaire pour vérifier que la
valeur est correcte. Par contre, ça ne me dit toujours pas comment
récupérer la charge par process... Si je trouve, je le posterai ici. On
ne sait jamais, ça pourrait aider quelqu'un !!
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
16 juin 2006 à 22:41
 Bonsoir à tous les lecteurs de ce topic,

Re-bon (jour, soir) Johann,

J'ai testé "ton script".
Il ne resoud pas ton problème !!! Moins d'informations exploitables
par rapport au 1er WMI proposé.

jean-marc

Je reste attentif à l'évoluation de topic, car je peux en avoir utilité pour mon job (voir fiche JMO).

Bonne soirée, et donc, sous-entendu, programme prog accompagnée par
les futurs topics.

jean-marc
0
johann91 Messages postés 46 Date d'inscription jeudi 2 décembre 2004 Statut Membre Dernière intervention 21 juillet 2006
18 juin 2006 à 15:34
Re Jean-Marc et tous ceux qui suivent le sujet.

L'avantage de ce Win32_Processor est qu'on a accès aux infos matériel, comme la charge du processeur, donnée dont j'ai besoin. Bien sûr, il y a plein d'infos dont je n'a pas besoin, mon but étant de vérifier l'utilisation des ressources matériel pendant l'exécution d'un script. Le Win32_process permet de connaître l'utilisation de la mémoire.
Ce que je veux, c'est :
 - l'utilisation mémoire
       => Pour un processus en particulier (java.exe)
       => totale
 - l'utilisation du CPU
       => pour java.exe
       => totale.

La seule donnée qui me manque est l'utilisation du CPU pour java.exe.

Voilà, bon week end !!!
0
Rejoignez-nous