내 자신의 질문에 답하는 것이 싫지만 다음 사람이이 문제에 직면 할 수있게하기 위해 System.Management 개체를 통해보다 쉬운 방법을 찾았습니다.
codeproject.com에 소스 코드가 포함 된 완전한 작동 응용 프로그램이 있습니다.
http://www.codeproject.com/KB/cs/Remote_process_controller.aspx
나는 꽤 내 선택은 특정 목적으로 수정하고,이 작업을 수행하는 가장 작은 funciton을 얻었다. 나는 다음 사람이 오기 위해 그것을 나눠주고있다.
System.Management에 대한 참조를 프로젝트에 추가해야합니다.
private bool CheckForExpectedProcess(string userName, string password, string machineName, string logonDomain, string PartialProcessname)
{
bool ReturnValue = false;
System.Management.ManagementScope managementScope;
try
{
System.Management.ConnectionOptions connOptions = new System.Management.ConnectionOptions();
connOptions.Impersonation = System.Management.ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
connOptions.Username = logonDomain + "\\" + userName;
connOptions.Password = password;
managementScope = new System.Management.ManagementScope(@"\\" + machineName + @"\ROOT\CIMV2", connOptions);
managementScope.Connect();
System.Management.ManagementObjectSearcher objSearcher = new System.Management.ManagementObjectSearcher("SELECT Name FROM Win32_Process WHERE NAME LIKE'%" + PartialProcessname + "%'");
System.Management.ManagementOperationObserver opsObserver = new System.Management.ManagementOperationObserver();
objSearcher.Scope = managementScope;
string[] sep = { "\n", "\t" };
System.Management.ManagementObjectCollection objects = objSearcher.Get();
ReturnValue = objects.Count > 0;
}
catch (Exception ex)
{
// handle error - we log it to our own system, but it's up to you.
}
return ReturnValue;
}
정확히 내가 필요로했던 것, 공유 주셔서 감사합니다 ... – Moshisho