c# - Process ID of RDP File -
i trying process id of .rdp file opened process , kill button1_click visual studio throws error process id doesn't exit. checked taskbar , rdp file has different process id , not 1 captured following code. if call mstc.exe, works fine , able kill process without error. can me this.
private void button1_click(object sender, eventargs e) {     pids.clear();     process myprocess = new process();     myprocess.startinfo.filename = "c:\\rdp\\remotein.rdp";       //notepad.startinfo.filename = "mstsc.exe";                     myprocess.start();             pids.add(myprocess);           }  private void terminateall() {               foreach (var in pids)     {        // process p = process.getcurrentprocess();         i.kill();     } }  private void button2_click(object sender, eventargs e) {     terminateall(); } 
when start non exe file via process class use shellexecute function lookup handler file indireclty launch process.  
fortunatly mstsc.exe take command line paramters, can launch mstsc.exe , directly.
myprocess.startinfo.filename = "mstsc.exe";                 myprocess.startinfo.arguments = "c:\\rdp\\remotein.rdp";   myprocess.start();    
Comments
Post a Comment