OVH Cloud OVH Cloud

Out of memory

2 réponses
Avatar
Exki
Hello !

Bon j'utilise un petit programme en vbs pour surveiller la
presence d'un process mais au bout d'un certain nombre de
jour, il ne marche plus et j'ai un message d'erreur. Help
me !!!!

Le programme :

Do
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!" &_
"\\" & strComputer & "\root\cimv2")

Set objEventSource = objSWbemServices.ExecNotificationQuery
( _
"SELECT * FROM __InstanceOperationEvent " &_
"WITHIN 1 " &_
"WHERE TargetInstance " &_
"ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'OmsServer.exe'")

Set objEventObject = objEventSource.NextEvent()
Select Case objEventObject.Path_.Class
Case "__InstanceCreationEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:\outils\batchs\message.bat " & 1)
Case "__InstanceDeletionEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:\outils\batchs\message.bat " & 2)
End Select
Loop


Le message d'erreur :

Line 7
Char 1
Error Out of memory

Code : 80041006
Source : SWbemServices


Merci @ vous tous

2 réponses

Avatar
HECHT Franck
Salut,

Je suis pas un pro dans ce genre de programmation mais tu
ne détruit jamais tes variables objets une fois qu'elles
ne sont plus utilisées ??

Set TaVariable = Nothing ??

-----Message d'origine-----
Hello !

Bon j'utilise un petit programme en vbs pour surveiller


la
presence d'un process mais au bout d'un certain nombre


de
jour, il ne marche plus et j'ai un message d'erreur.


Help
me !!!!

Le programme :

Do
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!" &_
"" & strComputer & "rootcimv2")

Set objEventSource =


objSWbemServices.ExecNotificationQuery
( _
"SELECT * FROM __InstanceOperationEvent " &_
"WITHIN 1 " &_
"WHERE TargetInstance " &_
"ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'OmsServer.exe'")

Set objEventObject = objEventSource.NextEvent()
Select Case objEventObject.Path_.Class
Case "__InstanceCreationEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 1)
Case "__InstanceDeletionEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 2)
End Select
Loop


Le message d'erreur :

Line 7
Char 1
Error Out of memory

Code : 80041006
Source : SWbemServices


Merci @ vous tous


.



Avatar
François Picalausa
"Exki" a écrit dans le message de
news:056201c3bd73$1e33b620$
Hello !

Bon j'utilise un petit programme en vbs pour surveiller la
presence d'un process mais au bout d'un certain nombre de
jour, il ne marche plus et j'ai un message d'erreur. Help
me !!!!

Le programme :

Do
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!" &_
"" & strComputer & "rootcimv2")

Set objEventSource = objSWbemServices.ExecNotificationQuery
( _
"SELECT * FROM __InstanceOperationEvent " &_
"WITHIN 1 " &_
"WHERE TargetInstance " &_
"ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'OmsServer.exe'")

Set objEventObject = objEventSource.NextEvent()
Select Case objEventObject.Path_.Class
Case "__InstanceCreationEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 1)
Case "__InstanceDeletionEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 2)
End Select
Loop


Le message d'erreur :

Line 7
Char 1
Error Out of memory

Code : 80041006
Source : SWbemServices


Merci @ vous tous



Bonjour/soir,

Peut-être détruire l'objet à chaque fois?
Set objEventSource = Nothing

Si les objets possèdent quelquechose s'apparentant a une méthode
close/quit/..., l'apeller avant le Set ... = Nothing

peut être aussi ne pas réinitiliaser les objets qui restent fixes?


strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!" & _
"" & strComputer & "rootcimv2")

Do
Set objEventSource = objSWbemServices.ExecNotificationQuery ( _
"SELECT * FROM __InstanceOperationEvent " & _
"WITHIN 1 " & _
"WHERE TargetInstance " & _
"ISA 'Win32_Process' " & _
"AND TargetInstance.Name = 'OmsServer.exe'")

Set objEventObject = objEventSource.NextEvent()

Select Case objEventObject.Path_.Class
Case "__InstanceCreationEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 1)
Case "__InstanceDeletionEvent"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("C:outilsbatchsmessage.bat " & 2)
End Select

'objEventObject.Close
Set objEventObject = Nothing
Loop

Set objSWbemServices = Nothing

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com