The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> IBM/Rational Robot

Pages: 1
NiteshBansal
Newbie


Reged: 01/28/09
Posts: 17
How to Kill Window Processes
      #577146 - 06/29/09 05:04 AM

Hi,

Is there any way by which we can kill any process currently running on system.

Also is there any in-built method available in Rational Robot by which we can start or stop service or we need to automate that process also.

With Best Regards,
Nitesh Bansal


Post Extras: Print Post   Remind Me!   Notify Moderator  
Berzins
Junior Member


Reged: 02/27/05
Posts: 68
Loc: Latvia
Re: How to Kill Window Processes [Re: NiteshBansal]
      #577172 - 06/29/09 06:03 AM

To kill process:
SQAShellExecute + taskkill

To start service (on server) I use
SQAShellExecute + psexec

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx


Post Extras: Print Post   Remind Me!   Notify Moderator  
flhs1993
Newbie


Reged: 07/06/09
Posts: 1
Re: How to Kill Window Processes [Re: NiteshBansal]
      #578338 - 07/06/09 07:19 AM

put the following at the top of your file outside the main function or in a library file. It is a user32.dll function.

declare function PostMessage& Lib "user32" Alias "PostMessageA" _
(ByVal hwnd as Long, ByVal wMsg as Long, ByVAl wParam as long, lParam as Any)

And this is the function you will create.

Function Kill_Obj_By_Hwnd(hwnd as long)
Dim lResult As Long
Dim iNoError As Integer
lResult = PostMessage(hwnd, WM_CLOSE, 0, 0)
End Function

All you need to pass is the object handle and your function is dead. If you have multiple objects ie: browsers, then you will have to do something like this below. U will have to know what your looking for to use the "FindWindow" function.

' "FindWindow" - Used to find windows handle for Excel.
' "PostMessage" - Sends message to O/S to terminate process
' using the "WM_CLOSE" message.

'used to find window handle for excel
declare function FindWindow Lib "user32" lias "FindWindowA"
(ByVal lpClassName as string, ByVal lpWindowName as String) as Long

'Sends message to o/s to terminate excel process
declare function PostMessage& Lib "user32" Alias "PostMessageA" (ByVal hwnd as Long, ByVal wMsg as Long, ByVAl wParam as long, lParam as Any)

'This function kills all active excel objects
Function KillExcel() As Integer
Dim lResult As Long
Dim hwnd As Long
Dim iNoError As Integer

hwnd=1
iNoError = sqaPass
DO WHILE hwnd > 0
hwnd = FindWindow("XLMAIN", "Microsoft Excel")
if hwnd > 0 then
lResult = PostMessage(hwnd, WM_CLOSE, 0, 0)
End if
LOOP

End Function


To use the above, you will need to know the 2 parameters used in the "FindWindow" function (a built in windows function.)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 6 anonymous users are browsing this forum.

Moderator:  AJ, RSBarber 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 2537

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5