C#

2012-10-28 6 views
0

을 사용하여 compmgmnt.msc를 원격 호스트에 연결합니다. C#을 사용하여 원격 호스트에 compmgmnt.msc를 어떻게 사용할 수 있습니까? 내가 이걸 발견 ...C#

가 작동하고 "cmd.exe를"이 명령을 실행하고 암호를 묻습니다 :

/user:administrator \"mmc.exe compmgmt.msc /computer:IZADI-PC\ 

하지만 난 C#에서이 명령을 사용하는 방법을 알 필요가 . 또한 C#을 사용하여이 명령에 암호를 전달해야합니다. 나는 원격 컴퓨터의 사용자 이름과 암호를 갖고 있으며 프로그래밍으로 모든 것을하고 싶다.

은 또한 방문 :

http://www.lansweeper.com/forum/yaf_postst5116_Runas-Custom-Actions.aspx Process.Start with different credentials with UAC on

고급에 감사드립니다!

사람이 C#에서

+0

사람의 도움을 /user:administrator \"mmc.exe compmgmt.msc /computer:IZADI-PC\을 excecute하는 샘플 코드를 작성! –

+0

http://stackoverflow.com/questions/4106628/start-process-with-administrator-right-in-c-sharp –

+0

내가 찾고있는 게 아닙니다 !!! –

답변

0
ProcessStartInfo startInfo = new ProcessStartInfo(); 
       Process myprocess = new Process(); 
       myprocess.StartInfo.CreateNoWindow = true; 
       myprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
       myprocess.StartInfo.UseShellExecute = false; 
       myprocess.StartInfo.Verb = "runas"; 
       myprocess.StartInfo.FileName = "cmd.exe"; 
       myprocess.StartInfo.UserName = "administrator"; 
       myprocess.StartInfo.Password = MakeSecureString("123456"); 
       myprocess.StartInfo.Arguments = "/k mmc.exe compmgmt.msc /computer:PC135-PC"; 
       myprocess.Start(); 
       myprocess.Close();