i am using below code but showing error like - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
var option = new ConnectionOptions();
option.Username = sys_admin_user_txt.Text;
option.Password = sys_admin_password_txt.Text;
var Kill = exe_name_txt.Text;
//string Kill = exe_name_txt.Text;
ManagementScope scope = new ManagementScope(@"\\"+ ftp +"\\root\\cimv2", option);
// WMI query
var query = new SelectQuery("select * from Win32_process where name = '" + Kill + "'");
using (var searcher = new ManagementObjectSearcher(scope, query))
{
foreach (ManagementObject process in searcher.Get()) // this is the fixed line
{
process.InvokeMethod("Terminate", null);
}

Manas MohapatraRank #182 · 13.2K reputationPosted Jul 27, 2015, 12:40 AM EDT
Feroz KhanRank #3,748 · 395 reputationPosted Jul 27, 2015, 3:25 AM EDT
Feroz KhanRank #3,748 · 395 reputationPosted Jul 27, 2015, 3:35 AM EDT
Raja TRank #685 · 3.5K reputationPosted Jul 27, 2015, 8:58 AM EDT
Please check out bellow URLs
http://forums.iis.net/t/1216194.aspx?Access+is+denied+Exception+from+HRESULT+0x80070005+E_ACCESSDENIED+
https://social.msdn.microsoft.com/Forums/en-US/26accc30-9cfb-4d86-9c27-780f51929ecb/access-is-denied-exception-from-hresult-0x80070005-eaccessdenied?forum=vsreportcontrols
http://forums.asp.net/t/1225290.aspx?Access+is+denied+Exception+from+HRESULT+0x80070005+E_ACCESSDENIED+