C# bring window to front in Kiosk mode

Betz, Dominik 16 Reputation points
2022-11-10T06:07:23.44+00:00

Hi there,

I have a client that is running in Windows 10 Multi App Kiosk Mode. The user has two tiles that he can start. As these tiles sometimes disappear when updating the apps behind it, I wrote two C# console applications that start these apps. I'd like to have some kind of workflow that first starts app A (VPN client) then waits until the VPN connection is established and afterwards starts app B. Therefore I implemented in App B that it waits until the connection is established and then starts App B. The VPN client started through my app comes to the front, the second app is started but hidden in the background. So the user would have to bring it to the front by pressing Alt+Tab.

What I've tried so far is to bring the window to the front by using the following code:

 [DllImport("user32.dll")]  
 private static extern bool SetForegroundWindow(IntPtr hWnd);  
      
 [DllImport("user32.dll")]  
 private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);  
      
 [DllImport("user32.dll")]  
 private static extern bool IsIconic(IntPtr hWnd);  
  
  
private static void BringToFront(Process processToFocus)  
{  
     IntPtr hWnd = processToFocus.MainWindowHandle;  
  
     if (IsIconic(hWnd))  
     {  
          ShowWindow(hWnd, 1);  
          SetForegroundWindow(hWnd);  
     }  
     else  
     {  
          SetForegroundWindow(hWnd);  
     }  
  
}  
  
  

The kiosk mode is configured via Intune configuration profile. In that profile I've set the first app to autostart but unfortunately I can't set the second app to also autostart.

Any ideas how to solve this? If my question is not placed in the correct forum, please let me know.

Thanks in advance.

Microsoft Intune Configuration
Microsoft Intune Configuration
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Configuration: The process of arranging or setting up computer systems, hardware, or software.
1,733 questions
{count} votes