Probleme script VBS : "Out Of memory"
exki
-
mustang -
mustang -
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
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
A voir également:
- Probleme script VBS : "Out Of memory"
- Vbs windows - Accueil - Optimisation
- Script vidéo youtube - Guide
- Ghost script - Télécharger - Polices de caractères
- Mas script - Accueil - Windows
- Script cmd - Guide
2 réponses
Bonjour exki
Je pense que ton pb vient du fait que tu ne sort jamais de la boucle. donc ton script charge en memoire et fini par saturer la memoir.
car si je voit bien tu declare ton objet a chaque boucle ce qui n'est pas tres propre en faire.
essaye plutot ca :
bon courage
Lord Mathius a votre service.
Je pense que ton pb vient du fait que tu ne sort jamais de la boucle. donc ton script charge en memoire et fini par saturer la memoir.
car si je voit bien tu declare ton objet a chaque boucle ce qui n'est pas tres propre en faire.
essaye plutot ca :
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'")
For I = 1 To 10000
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
Next
Set objEventSource = nothing
Set objSWbemServices = nothing
Loop
bon courage
Lord Mathius a votre service.