Process.kill()具有管理员权限被拒绝在Windows 7 32位甚至 [英] Process.kill() denied in Windows 7 32bits even with Administrator privileges
问题描述
您好每一个人。
我面临着一个奇怪的问题。我的应用程序,在IE浏览器的情况下进入一种状态是它得到响应这种方法被触发关闭所有IE浏览器进程的,然后在应用程序重新启动其与IE浏览器工作的简单方法。
方法code:
的foreach(的System.Diagnostics.Process EXE在System.Diagnostics.Process.GetProcesses())
{
如果(exe.ProcessName.StartsWith(IEXPLORE))
exe.Kill();
}
即使我调试具有管理员权限的应用程序的应用程序有时会成功运行,这种方法和其他一些时候,我得到的错误访问被拒绝
甚至以管理员身份运行。
我甚至codeD我自己的清单文件中指定需要该应用程序将使用管理员权限执行,我想我是正确的。
清单code:
< XML版本=1.0编码=UTF-8&GT?;
< asmv1:装配manifestVersion =1.0的xmlns =瓮:架构 - 微软COM:asm.v1的xmlns:asmv1 =瓮:架构 - 微软COM:asm.v1的xmlns:asmv2 =金塔:架构 - 微软-COM:asm.v2的xmlns:XSI =http://www.w3.org/2001/XMLSchema-instance>
< assemblyIdentity版本=1.0.0.0NAME =Demo.app/>
< trustInfo的xmlns =瓮:架构 - 微软COM:asm.v2>
<安全>
< requestedPrivileges的xmlns =瓮:架构 - 微软COM:asm.v3>
< requestedExecutionLevel水平=requireAdministratoruiAccess =FALSE/>
< / requestedPrivileges>
< /安全>
< / trustInfo>
<兼容的xmlns =瓮:架构 - 微软COM:compatibility.v1>
<应用>
< /用途>
< /兼容性>
< / asmv1:装配>
任何人之前有同样的问题?我怎样才能解决这个奇怪的问题。
感谢
既然你说你永远拥有管理员权限,当您试图调用此方法,下面会解释为什么你的间歇的问题
System.Diagnostics.Process.Kill :
如果在调用
杀
方法,而这个过程正在终结,取得了Win32Exception
被抛出访问被拒绝。
如果你赶紧打删除+确定两次,在工艺,资源管理器中的条目,你就会知道我在说什么。
Hello every one.
I'm faced with a weird problem. My application has a simple method that in case IE enters a state were it gets unresponsive this method is fired closing all IE process's and then the application restarts its work with IE.
Method code:
foreach (System.Diagnostics.Process exe in System.Diagnostics.Process.GetProcesses())
{
if (exe.ProcessName.StartsWith("iexplore"))
exe.Kill();
}
Even debugging my application with Administrator privileges the application sometimes runs this method successfully and some other times i get the error Access Denied
even running as Administrator.
I even coded my own manifest file specifying the need for this application to be executed with Administrator rights, which i think i got it right.
Manifest Code:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="Demo.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
Anyone had this same issue before? How can i correct this weird problem.
Thanks
Given that you say you always possess administrative privileges when you attempt to call this method, the following would explain why you have intermittent issues:
System.Diagnostics.Process.Kill:
If the call to the
Kill
method is made while the process is currently terminating, aWin32Exception
is thrown for Access Denied.
If you've quickly hit 'delete' + 'OK' twice, on an entry in Process-Explorer, you'll know what I'm talking about.
这篇关于Process.kill()具有管理员权限被拒绝在Windows 7 32位甚至的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!