473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Raise an alert when a Application Starts

I need to monitor for when an exe (application) starts. This will
trigger an alert. The application will be one the user starts and
monitoring will be only required on the pc they are logged in on.

Could someone direct me to what the best way to do this is.

Regards
Jeff
May 14 '07 #1
1 1748
On May 14, 2:34 pm, Jeff Williams
<jeff.williams_NO_S...@hardsoft.com.auwrote:
I need to monitor for when an exe (application) starts. This will
trigger an alert. The application will be one the user starts and
monitoring will be only required on the pc they are logged in on.

Could someone direct me to what the best way to do this is.

Regards
Jeff
Dear Jeff,

you can watch for WMI events (System.Managment namespace, .NET 2.0)

// Create event query to be notified within 1 second of
// a change in a process
string query =
"SELECT * FROM __InstanceCreationEvent "
+ "WITHIN 1 WHERE " +
"TargetInstance isa \"Win32_Process\"";

// Initialize an event watcher and subscribe to events
// that match this query
ManagementEventWatcher watcher =
new ManagementEventWatcher(new EventQuery(query));

// times out watcher.WaitForNextEvent in 20 seconds
watcher.Options.Timeout = new TimeSpan(0, 0, 20);

// Block until the next event occurs
// Note: this can be done in a loop if waiting for
// more than one occurrence
Console.WriteLine(
"Open an application (notepad.exe) to trigger an
event.");
ManagementBaseObject e = watcher.WaitForNextEvent();

//Display information from the event
Console.WriteLine(
"Process {0} has been created, path is: {1}",
((ManagementBaseObject)e
["TargetInstance"])["Name"],
((ManagementBaseObject)e
["TargetInstance"])["ExecutablePath"]);
Console.ReadLine();
//Cancel the subscription
watcher.Stop();
return 0;

This sample is from MSDN.

That's an off-handed idea, there might be better solutions.

Moty

May 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
2
by: Mortimer Schnurd | last post by:
Hi, I've been dabbling with C# for a short time now but am ready to use it in extending/converting older VB6 applications. I have one VB6 application I am now working to extend and I would like to...
5
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can...
2
by: Nikhil Patel | last post by:
Hi all, How can I raise the Click event of the LinkButton server control in Javascript? Thanks.
7
by: Phil Mc | last post by:
Hi all I have a small scheduling application that I have written which will be running on a Windows 2003 server. This application is started at different times by an 'autosys' job (though I am...
8
by: simon | last post by:
hello. hopefully another quick newbie question for you.... I have a codebehind function coded to handle the click event of a button. what this function does is insert values from a data grid...
1
by: Joris Lambrecht | last post by:
Hi people, Please take a look at the issue i talk about below. (yes i do realise such functions are publicaly available) The page i'm using uses JSON defined array of image files with...
24
by: Steven D'Aprano | last post by:
Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread...
1
by: Naushad | last post by:
Hi All Our Company is provided courses to employees for one or more days i.e. there are three field (EmpNo, StartDate and EndDate) of course. I am trying to display an Alert message when a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.