Timon Timon - 4 years ago 167
C# Question

Start UI on server from web application

I'm trying to get a UI ( browsers like chrome, firefox, IE, ... ) running using a web application.

When i use the following code (on my local machine and on a server)

Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
Process.Start(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe");


in a console application this is no problem. All three start up with no issues.

class Program
{
static void Main(string[] args)
{
Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
...
}
}


When i try this from a controller method, this does not work.

public class MyController : Controller
{
public ActionResult QuickStart()
{
Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
...
}
}


If i start my own custom executable it does run ( my test executable writes a file to the disk ) but it doesn't show the console that it is supposed to. )

From what i've found this is because the system doesn't have any context as for what user this ui would have to be shown ? So i tried impersonating every possible user ( doesn't work because impersonating isn't the same as getting the current session as a logged in user ? ) and i've tried starting the process for every possible WindowsIdentity possible and yet still notting happend.

Does anyone know what i could do to make this work ?

Answer Source

Whenever your app uses other credentials it creates a new session. To get round this you would need to make a small systray type app so you can login as some account and run this app which listens for commands from your service, and then pops up on that session whatever it is you need it to, and it will be visible to the user that intermediary app runs as.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download