is there any ay to end a process from the windows task manager using a QTP script?
I'd like to end a process using it's image name.
"I realize it's an error, but no one is going to try to do that!"
From "Top 10 Stupid Comments from Developers".
Yes. I have scripted tests to actually use TaskManager to end a process. Add it to your repo and interact as you usually would. Here's my scripting:
SystemUtil.Run "C:\Windows\System32\TaskMgr.exe","","C:\Windows\S ystem32",""
Dialog("Windows Task Manager").WinTab("SysTabControl32").Select "Processes"
Dialog("Windows Task Manager").WinListView("SysListView32").Select "YourAppsImageName.exe"
Dialog("Windows Task Manager").WinButton("End Process").Click
Dialog("Windows Task Manager").Dialog("Task Manager Warning").WinButton("Yes").Click
An easier alternate that may or may not work for you in your scenario is to use the built-in QTP function:
SystemUtil.CloseProcessByName or .CloseProcessByID
... whose implementation details you can read about in qtp help.
If ya got beef then fool eat a pork chop.
Why not use the SystemUtil.CloseProcessByName method???
Buy the NEW QTP Descriptive Programming Unplugged Book
** Download QTP Unplugged 2nd Edition eBook for FREE **
I use both methods in my tests, as they close / terminate the process differently.
both ways works fine.