0
Answer

Topmost window focus

jesu raj

jesu raj

8y
348
1
I have a very strange issue.
I have two application.
For example:
Process1.exe launching Process2.exe. (This is done using Process.WaitForExit(), Process1 will wait till Process2 gets closed.)
Sample code for this case.
 
  1. Process p = new Process();  
  2. p.StartInfo.FileName = strFilePath;  
  3. string strDirectory = System.IO.Path.GetDirectoryName(strFilePath);  
  4. p.StartInfo.WorkingDirectory = strDirectory;  
  5. p.Start();  
  6. p.WaitForExit();  
 
Now the Process2.exe is launching remote desktop using a pre-configured RDP(Remote Desktop Protocal) file.
This is done by using the below code.
 
 
  1. System.Diagnostics.Process remoteWindow = new System.Diagnostics.Process();  
  2. remoteWindow.StartInfo.FileName = MSTSC_PROCESS_NAME;  
  3. remoteWindow.StartInfo.Arguments = strUrl;  // RDP file path
  4. remoteWindow.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;  
  5. result = remoteWindow.Start();  
Now the issue is when we close the remote desktop window, focus is moving to Process1.exe. Actually windows should retain focus on Process2.exe
Also, this issue is not occuring in all kind of PC's. This issue is occurring specifically in Panasonic CF-C1 laptop.
 
OS: Windows 7
 
Is this a windows related issue? or Any suggestions will help.