Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » How to Close Any Application From VBA,QTP,VBScript




This is the code where you can close any application.Even from QTP You can give this command to stop any application.

Logic

The steps are...
1. Go to Task Manager.
2. Find out which application you want to close.
3. Right click on it.
4. Go to process and Select it.
5. It will navigate you to Process page.
6.Just remember the process name of the corresponding application.


















































Checkout the process:








Now pass the processname below my code.




Private Function CloseAppliction()
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = qlock.exe'")
For Each objProcess in colProcess
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcess = Nothing
End Function




again,say i will close excell,...






Public Function fn_close_all_excel_files()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'EXCEL.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
End Function



«
Next
Newer Post
»
Previous
Older Post

No comments:

Leave a Reply