'Code to close all Internet explorer browser process using QTP Dim oWMIService, allIExplorer,iEItem Dim strComputer strcomputer="." 'Get the WMI object Set oWMIService=GetObject("Winmgmts:\\"& strcomputer & "\root\cimv2") 'Get collection of processes for with name iexplore.exe set allIExplorer=obj.execquery("Select * from win32_process where name='iexplore.exe'") name 'Loop through each process and terminate it For each iEItem in allIExplorer iEItem.terminate Next Set allIExplorer= Nothing Set oWMIService= Nothing
Click here for similar QTP scripts.
This code is only working for QTP 11.0, IE7 and Windows XP environment. But if the same code will execute in Windos7, IE8 than error will occur.
ReplyDeleteIf you have solution for Window 7 and IE8 than please send me on pardeepohri@gmail.com
ReplyDeleteset allIExplorer=obj.execquery("Select * from win32_process where name='iexplore.exe'")
ReplyDeletein above line replace 'obj' with 'oWMIService'