11

I am trying to start a windows application from a windows Service using the below code

Process.Start(@"filename.exe");

In windows 7 I receive a popup that says, "A program running on this computer is trying to display a message"

Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60
  • you can use windows task scheduler please see [this way](https://stackoverflow.com/questions/5307968/how-can-i-run-an-exe-program-from-a-windows-service-using-c/51156657#51156657) . – Rahmat Anjirabi Jul 03 '18 at 14:13

3 Answers3

5

You cannot start an interactive application from a Windows Service. This was changed in Windows Vista and 7.

Some other advice was given in this Stack Overflow answer on the same subject.

When I've needed to do this, I had to change my Windows Service to a Console Application, and invoked it in that manner.

Community
  • 1
  • 1
George Stocker
  • 57,289
  • 29
  • 176
  • 237
3

A work-around I found for this issue was to use the windows task scheduler. You can schedule the application to run some amount of seconds later by creating a batch file.

Andrew
  • 31
  • 1
1

At my previous company we had this issue and we wrote a console app that ran in the sys tray and acted as a bridge from the service to the desktop. Basically via remoting (I'd use WCF now of course) we let the service request that the console app start up another application.

juharr
  • 31,741
  • 4
  • 58
  • 93