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

  • Home
  • SEARCH
  • 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 8402419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:03:29+00:00 2026-06-09T22:03:29+00:00

I am trying to create an app which monitors for process creation/termination and logs

  • 0

I am trying to create an app which monitors for process creation/termination and logs the amount of time it executed and its frequency which is finally being logged in mysql db. The problem that I am facing is that, I am using Win32_ProcessStartTrace and Win32_ProcessStopTrace for monitoring. As soon a process is created, its commandline is being queried using Win32_Process. There seems to be a “lag” between Process creation and the querying of its commandline for those processes which exit quickly so I can’t get the commandline.

Is there any way of getting this done?

  • 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-06-09T22:03:31+00:00Added an answer on June 9, 2026 at 10:03 pm

    This code watches for new processes starting and prints the command line used:

    using System;
    using System.Management;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                new Test().Run();
                Console.ReadLine();
            }
        }
    
        internal class Test
        {
            public void Run()
            {
                ProcessWatcher procWatcher = new ProcessWatcher();
                procWatcher.Start();
            }
    
            private class ProcessWatcher : ManagementEventWatcher
            {
                private const string wql = 
                       @"SELECT * FROM __InstanceCreationEvent WITHIN 1
                         WHERE TargetInstance ISA 'Win32_Process'";
    
                public ProcessWatcher()
                {
                    this.Query.QueryLanguage = "WQL";
                    this.Query.QueryString = wql;
                    this.EventArrived += newProcessStarted;
                }
    
                private void newProcessStarted(object sender, 
                                               EventArrivedEventArgs e)
                {
                    var process = e.NewEvent["TargetInstance"] 
                                  as ManagementBaseObject;
    
                    if (process != null)
                    {
                        var cmdLine = process.Properties["CommandLine"].Value;
                        Console.WriteLine(cmdLine);
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an app which uses a combination of jQuery templates
I'm trying to create an app which plays videos from a file using AVFoundation
I am trying to create an android app which will show multiple web urls
I've been trying very very hard to create a simple simple iOS app which
I'm trying to create an app which scans ports of given IP address individually
I'm trying to create an iphone app which grabs a JSON string, parses it
I am trying to create a simple app in WP7 which will show traffic
I was trying to create an app using Bing Map. in which i need
I am trying to create an App which takes the GPS co-ordinates of my
I am trying to create an app in which, I need navigation bar button

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.