Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. launching programs from a windows service

launching programs from a windows service

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NikoTanghe
    wrote on last edited by
    #1

    I wrote a windows service that runs under the system account. This service should launch other programs and monitor them, so it's a kind of a watchdog. I use the System.diagnostics.process class to launch these programs. The code is working perfectly when I run this in a simple console. but this doesn't work in the service. Process.start() simply returns, no program is launched, no exception is thrown... what is wrong here ? Is there another approuch that I can try? gr, Niko

    << Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>

    D 1 Reply Last reply
    0
    • N NikoTanghe

      I wrote a windows service that runs under the system account. This service should launch other programs and monitor them, so it's a kind of a watchdog. I use the System.diagnostics.process class to launch these programs. The code is working perfectly when I run this in a simple console. but this doesn't work in the service. Process.start() simply returns, no program is launched, no exception is thrown... what is wrong here ? Is there another approuch that I can try? gr, Niko

      << Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      NikoTanghe wrote:

      Process.start() simply returns, no program is launched, no exception is thrown... what is wrong here ?

      The problem is you don't understand how services work. Services run under their own desktop, NOT the users desktop that you can see. The Process.Start() code worked. The application was launched. All you have to do is open TaskManager and click on the Processes tab to see that. You have to configure your service to interact with the users desktop. Click Start/Run, then type SERVICES.MSC and hit enter. Find your service in the list and double-click it. Click on the LogOn tab and find the little check box that says something like "Allow server to interact with desktop" and enable it. Now, YOU HAVE A MUCH BIGGER PROBLEM. Services run all the time, even when noone is logged into the machine. So, with no user desktop to show an app, you're service will still launch the applications, but noone will ever see them because there is no user desktop! Just logging into the machine will NOT automatically show you the launched applications either. They will be running, but on the services desktop only. There is no way to transfer the application between desktops. In order for the logged in user to see them, the applications would have to be killed and restarted. Notice, in the .NET Framework's Service classes, that you don't get any "User logged on" events...

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups