I am currently working on a project that contains a WCF service, a Windows service and a WPF application. The Windows service communicates with the WCF, and under a certain circumstance, must launch the WPF application for the user to receive messages. (WCF is on a remote server, the rest is on the client). I've hit a bit of a snag with the launch. I have the services writing messages to the application logs so that I can somewhat 'debug' along the way. The Windows service runs the following code with no problems.
C# code, Windows Service:
WriteLog.WriteString("PostOffice.MessagesWaiting: Inside, starting up.", EventLogEntryType.Warning);
var messagingProcess = new Process();
var messageProcessStartInfo = new ProcessStartInfo(@"""C:\GoldenEyeMessages.exe""");
messageProcessStartInfo.CreateNoWindow = false;
messageProcessStartInfo.UseShellExecute = false;
messageProcessStartInfo.FileName = @"""C:\GoldenEyeMessages.exe""";
messageProcessStartInfo.WindowStyle = ProcessWindowStyle.Normal;
messageProcessStartInfo.Verb = "runas";
messageProcessStartInfo.RedirectStandardOutput = true;
messagingProcess.StartInfo = messageProcessStartInfo;
messagingProcess.Start();
StreamReader daStreamReaderMan = messagingProcess.StandardOutput;
string newString = daStreamReaderMan.ReadLine();
WriteLog.WriteString("PostOffice.MessagesWaiting: The Eagle has landed.", EventLogEntryType.Warning);
The WPF application doesn't execute in the current user's session. Instead, I get a popup to view the message. Here is a picture of it:
http://employee.wassinkdesign.com/uploads/14_message.png[
^]
Once selecting the 'View the message' option, it of course switches me to a different session and then runs the WPF application.
My question is, how should I go about getting the WPF application to launch within the current user's session, or the 'active' session?
Thanks for any help!
// Just as a side note, I have done quite a few hours of research on this and understand that this is a security risk (shatter attacks, replacing the exe, etc...) but this has been accepted by my employer for this current situation.
// I noticed that supposedly Windows Vista OS and later doesn't allow communications with user accounts because of the security issues, but it does have the ability to impersonate users... I'm thinking that might be an option to look in to...