C#을 사용하여 원격 시스템에서 프로세스를 만들려고합니다.
나는 필요한 모든 매개 변수를 얻었으며 프로세스를 성공적으로 실행했지만 실제로는 볼 수 없습니다.
예를 들어, 여기에 메모장 프로세스를 실행하려고하는데 아무 창이 나타나지 않고 작업 관리자의 notepad.exe 프로세스 만 표시됩니다.win32_process.create가 창을 표시하지 않습니다.
public void ExecuteOnRemote(string username, string password)
{
ConnectionOptions connOptions = new ConnectionOptions
{
Impersonation = ImpersonationLevel.Impersonate,
EnablePrivileges = true,
Username = username,
Password = password
};
ManagementScope scope = new ManagementScope(@"\\remoteMachineName\root\cimv2", connOptions);
scope.Connect();
ObjectGetOptions options = new ObjectGetOptions();
// Getting the process class and the process startup class
ManagementPath processClassPath = new ManagementPath("Win32_Process");
ManagementPath processStartupClassPath = new ManagementPath("Wind32_ProcessStartup");
ManagementClass processClass = new ManagementClass(scope, processClassPath, options);
ManagementClass processStartupClass = new ManagementClass(scope, processStartupClassPath, options);
// Settings the show window parameter in for a process startup class instance
ManagementObject processStartupInstance = processStartupClass.CreateInstance();
processStartupInstance["ShowWindow"] = 1; // A const value for showing the window normally
// Settings the parameters for the Create method in the process class
ManagementBaseObject inArgs = processClass.GetMethodParameters("Create");
inArgs["CommandLine"] = "notepad.exe";
inArgs["ProcessStartupInformation"] = processStartupInstance;
// Invoking the method
ManagementBaseObject returnValue = processClass.InvokeMethod("Create", inArgs, null);
}
내 생각 엔 ProcessStartupInformation 매개 변수를 잘못 보내고 있지만 문제가 어디인지 아직 알 수 없습니다.
도움이 될 것입니다.
고마워, 알렉스.
Hmya는이 기능의 악의적 인 사용에 대한 Microsoft의 우려를 절대로 과소 평가하지 않습니다. 로그인 대화 상자처럼 보이는 창을 표시하는 것은 물론 암호를 수집하는 좋은 방법입니다. notepad.exe는 격리 된 세션 0의 바탕 화면에 해당 창을 표시합니다. SysInternals의 PsExec 유틸리티 인 -i 옵션을 확인하십시오. –
고마워. 보안 기능인지 몰랐습니다. PsExec이 나를 위해 일했다. :-) –