2

I'm trying to launch a WPF .exe from my VisualWebGUI (winforms on the web basically) application. Everything works fine when I run it through VS2010. However when I deploy the site to IIS it does launch the .exe (I can see it writing out to a log file) but it does not show me the GUI of the WPF app. I can see the process running in Task Manager too! Very simple stuff really, just passing one arguement:

Process p = new Process();
p.StartInfo.FileName = Security.ExePath
p.StartInfo.Arguments = ID
p.Start();

I've tried fiddling around with the different startinfo parameters but to no avail, am I missing something?

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
  • 2
    When it is running in IIS it wont display on screen. Your applications App Pool will be running as a different user, so when you start the new process it will start as that user – Mike Norgate Nov 11 '13 at 16:23
  • 3
    When you run in IIS you are running as 'service'. A service does not have a desktop. Running an .exe on the server (IIS) through web page is not a good idea – Marvin Smit Nov 11 '13 at 16:24
  • 1
    Further to the above: your app is appearing during development because IIS is running on your machine. When you deploy your project to a server, *none of your users* will see the WPF application that you launch, regardless of the server configuration. – Dan Puzey Nov 11 '13 at 16:31
  • What are you trying to do? Launching a process from a web application is bad, trying to show a GUI is worse in terms of scalability. Additionally, unless you run the app pool as an account with logon rights (which is VERY BAD) no-one will ever be able to see the UI – Panagiotis Kanavos Nov 11 '13 at 16:33
  • Thanks for the comments everyone. Long story short what we were trying to do is capture a bunch of information in the VisualWebGUI app and then display some of this data to the user in a WPF form. WPF having some controls that were useful for the purpose of this project. – NickCasablancas Nov 11 '13 at 17:38

2 Answers2

0

That's may because the application is started under the AppPool identity (e.g. ApplicationPoolIdentity). Try to set the Identity under "Advanced Settings" for the AppPool to the User that is logged in and should see the application.

NKnusperer
  • 974
  • 1
  • 11
  • 31
0

You will need to specify proper window station for your process, in order for it to get access to the same UI as your current Windows logon session.

Look here: http://support.microsoft.com/kb/165194 and read on about Windows API, for example here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682429(v=vs.85).aspx

As a side note, launching GUI from a worker process is a really bad idea - primarily because you never guarantee that there IS any interactive user at any point in time. When you use IIS, your primary assumption must be that there is nobody looking at the server screen.

You'll be better off having your GUI application (or a lightweight stub) automatically started up when user logs on, and then listening for signals from the background process.

Roman Polunin
  • 53
  • 3
  • 12