Forum Discussion

smitad's avatar
smitad
Occasional Contributor
13 years ago

Killing a process from Task Manager

Hi,



I want to kill a exe from windows task manager. I used WMI. Following is the code

Killprocess = "CPR_GUI.exe"



Set ProcessList = GetObject("winmgmts://.").InstancesOf("win32_process")


ProcessList = GetObject("winmgmts://.").InstancesOf("win32_process")

For Each Process In ProcessList


Process ProcessList

If Process.Name = KillProcess Then


Process.Name = KillProcess

Process.Terminate



End If

Next



 




im getting an error n line 2 OLE Error 80041002 and a vbscript runtime error. all I want to do is kill CPR_GUI exe using test complete. If anyone has done this without error, please let me know how did you acheive it.



Regards

Smita

3 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    For killing processes use Sys.Process("process_name.exe").Terminate()
  • smitad's avatar
    smitad
    Occasional Contributor
    When i run it, it keeps waiting for the "process_name.exe" file. Is there another way. Do i need to add task manager object to it.
  • smitad's avatar
    smitad
    Occasional Contributor
    Hey Gennadiy thanks, it worked, the .exe was not needed. Thanks for it. Once it took longer to close the exe i think the OB was not refreshed. Need to refresh it before terminating.