Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 230553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:51:32+00:00 2026-05-11T19:51:32+00:00

I have some services that an application needs running in order for some of

  • 0

I have some services that an application needs running in order for some of the app’s features to work. I would like to enable the option to only start the external Windows services to initialize after the application is launched. (as opposed to having them start automatically with the machine and take up memory when the application is not needed)

I do not have access to the exe’s code to implement this, so ideally I would like to write a C# .Net Windows service that would monitor when an exe is launched.

What I’ve found so far is the System.IO.FileSystemEventHandler. This component only handles changed, created, deleted, and renamed event types. I don’t expect that a file system component would be the ideal place to find what I’m looking for, but don’t know where else to go.

Maybe I’m not searching with the right keywords, but I have not yet found anything extremely helpful on Google or here on stackoverflow.com.

The solution would be required to run on XP, Vista, and Win 7 when it comes…

Thanks in advance for any pointers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:51:32+00:00Added an answer on May 11, 2026 at 7:51 pm

    From this article, you can use WMI (the System.Management namespace) in your service to watch for process start events.

     void WaitForProcess()
    {
        ManagementEventWatcher startWatch = new ManagementEventWatcher(
          new WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace"));
        startWatch.EventArrived
                            += new EventArrivedEventHandler(startWatch_EventArrived);
        startWatch.Start();
    
        ManagementEventWatcher stopWatch = new ManagementEventWatcher(
          new WqlEventQuery("SELECT * FROM Win32_ProcessStopTrace"));
        stopWatch.EventArrived
                            += new EventArrivedEventHandler(stopWatch_EventArrived);
        stopWatch.Start();
    }
    
      static void stopWatch_EventArrived(object sender, EventArrivedEventArgs e) {
        stopWatch.Stop();
        Console.WriteLine("Process stopped: {0}"
                          , e.NewEvent.Properties["ProcessName"].Value);
      }
    
      static void startWatch_EventArrived(object sender, EventArrivedEventArgs e) {
        startWatch.Stop();
        Console.WriteLine("Process started: {0}"
                          , e.NewEvent.Properties["ProcessName"].Value);
      }
    }
    

    WMI allows for fairly sophisticated queries; you can modify the queries here to trigger your event handler only when your watched app launches, or on other criteria. Here’s a quick introduction, from a C# perspective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I haven't seen any information on the net regarding how… May 12, 2026 at 12:37 am
  • Editorial Team
    Editorial Team added an answer w:Anders Hejlsberg: In 1996, Hejlsberg left Borland and joined archrival… May 12, 2026 at 12:37 am
  • Editorial Team
    Editorial Team added an answer Given your previous question, you're generating this string as part… May 12, 2026 at 12:37 am

Related Questions

I am writing an application in C# that needs to run as a service
(If anything here needs clarification/ more detail please let me know.) I have an
I need a way of getting the active server address, port, and context during
I have a console application in C# in which I run various arcane automation

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.