Using System.Diagnostics.Process.Kill process

Ask general questions here.
Obessrour
Posts: 5
Joined: Fri Nov 07, 2014 2:29 pm

Using System.Diagnostics.Process.Kill process

Post by Obessrour » Fri Nov 07, 2014 3:09 pm

Hi,

I'm testing a desktop application using RS 5.2

I'm trying to kill some process after closing the application and i found some trouble there.

The error message show that i don't have enough privilege to execute the System.Diagnostics.Process.Kill() Sub, knowing that I'm using the administrator user of the Operating system.
Do I need some specified configuration for Ranorex ?

her is the Sud :


Public Sub killProcess()

For Each prog As Process In Process.GetProcesses
If prog.ProcessName = "processName" Then
prog.Kill()
prog.WaitForExit()
Report.Info("Killing the '" &prog.ProcessName & "' Process ")
End If
Next
End Sub


Regards,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Using System.Diagnostics.Process.Kill process

Post by Support Team » Mon Nov 10, 2014 3:43 pm

Hello Obessrour,

It seems like you don't have the necessary permission to “kill” the process. Please ensure that you are running your test/script with elevated rights. Even if you are running your script with Admin rights you won’t be able to kill “system critical” processes. You don’t need a special configuration of Ranorex in order to use the System.Diagnostics.Process.Kill()-method.

Regards,
Robert

Obessrour
Posts: 5
Joined: Fri Nov 07, 2014 2:29 pm

Re: Using System.Diagnostics.Process.Kill process

Post by Obessrour » Tue Nov 11, 2014 9:34 am

Hi Robert,


Thanks for your Response :)

Could you please clarify what did you mean by " Please ensure that you are running your test/script with elevated rights." ?


Best,

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Using System.Diagnostics.Process.Kill process

Post by krstcs » Tue Nov 11, 2014 2:28 pm

Elevated rights = Administrator type account. They are the only type of accounts that can end a process they don't own. You should be using an account with Administrator privileges to run tests.
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Using System.Diagnostics.Process.Kill process

Post by Support Team » Thu Nov 13, 2014 1:16 pm

Hello,

@krstcs
Thank you for answering the question. You are right. :wink:

Regards,
Robert

Obessrour
Posts: 5
Joined: Fri Nov 07, 2014 2:29 pm

Re: Using System.Diagnostics.Process.Kill process

Post by Obessrour » Thu Nov 13, 2014 3:01 pm

Thank you :)