I am adding security to one of my application. I would like that on Enable, C:\Windows\System32\mstsc.exe c:\thinclient\pekts00.rdp with .rdp (remote desktop) configured is launched. It will continue to run to check if mstsc.exe is running and will logoff windows or start it if it is not.
Asked
Active
Viewed 258 times
1 Answers
1
Try like below... It will help you...
System.Diagnostics.Process[] pname = System.Diagnostics.Process.GetProcessesByName("mstsc");
if (pname.Length == 0)
System.Diagnostics.Process.Start(Environment.GetEnvironmentVariable("windir") + @"\system32\mstsc.exe");

Pandian
- 8,848
- 2
- 23
- 33
-
+0 so far - you are missing a way to specify RDP file and please show correct way (%windir%) to specify path to mstsc. – Alexei Levenkov Apr 16 '13 at 15:56
-
@AlexeiLevenkov: i have edited my code... is this you except..? – Pandian Apr 16 '13 at 16:39
-
yes it helps thank you... I don't want to kill the process if it is running though, I just want to make sure it is ALWAYS running – Drew Salesse Apr 16 '13 at 16:45
-
@DrewSalesse: Thanks, If it helps you then mark it as answer, Then only it was easily identify to Others.. – Pandian Apr 16 '13 at 16:50
-
I need to launch to c:\thinclient\pekts00.rdp – Drew Salesse Apr 16 '13 at 17:19
-
@DrewSalesse: `System.Diagnostics.Process.Start(@"c:\thinclient\pekts00.rdp");` Try like this... it will launch the application – Pandian Apr 16 '13 at 17:22
-
+1. Also actual sample still missing specifying parameters to the application, your last comment provides a way to solve it. – Alexei Levenkov Apr 17 '13 at 02:04