在Windows上获取进程所有者名称 [英] Getting Process Owner Name on Windows
问题描述
您好,
我想在机器上获取进程所有者名称。我使用以下代码
I want to get the process owner name on machine . I am using the below code
string query =" Select * From Win32_Process Where ProcessID =" + 20636;
              ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
              ManagementObjectCollection processList = searcher.Get();
$
              foreach(processList中的ManagementObject进程)
              {
                  string [] argList = new string [] {string.Empty,string.Empty};
                  int returnVal = Convert.ToInt32(process.InvokeMethod(" GetOwner",argList));
$
              }
string query = "Select * From Win32_Process Where ProcessID = " + 20636;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection processList = searcher.Get();
foreach (ManagementObject process in processList)
{
string[] argList = new string[] { string.Empty, string.Empty };
int returnVal = Convert.ToInt32(process.InvokeMethod("GetOwner", argList));
}
当Visual Studio在管理模式下运行时,上面的代码工作正常。但是在非管理模式下,returnValue为2且arglist为空。
Above code works fine when Visual Studio is running in Admin Mode . However in Non-Admin mode , returnValue is 2 and arglist is empty.
是否有解决方案在非管理模式下获取进程所有者名称。
Is there a solution to get process owner name in Non Admin Mode.
Kapil Gupta
Kapil Gupta
推荐答案
在标准用户帐户下运行的流程没有足够的权限从所有其他进程获取所需的信息。 这只是标准Windows安全机制的结果。
A process running under a standard user account does not have sufficient privilege to obtain the desired information from all other processes. This is just a result of the standard Windows security mechanisms.
这篇关于在Windows上获取进程所有者名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!