473,698 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1765
On May 14, 2:34 pm, Jeff Williams
<jeff.williams_ NO_S...@hardsof t.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.Managme nt namespace, .NET 2.0)

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

// Initialize an event watcher and subscribe to events
// that match this query
ManagementEvent Watcher watcher =
new ManagementEvent Watcher(new EventQuery(quer y));

// times out watcher.WaitFor NextEvent 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.WriteLi ne(
"Open an application (notepad.exe) to trigger an
event.");
ManagementBaseO bject e = watcher.WaitFor NextEvent();

//Display information from the event
Console.WriteLi ne(
"Process {0} has been created, path is: {1}",
((ManagementBas eObject)e
["TargetInstance "])["Name"],
((ManagementBas eObject)e
["TargetInstance "])["ExecutablePath "]);
Console.ReadLin e();
//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
10518
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
5110
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 write the addition in C#. I've scoured the Internet for the procedures necessary to use this type of interoperability and feel comfortable with those so far (strong name, GAC, attributes, etc). My question: How does my C# component notify my...
5
2131
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 use remoting to talk to the UI components but I need an example of how to create an event when something happens on the UI (e.g. text box receives focus) and fire that via my object model back to any remote client. I also need the ability to...
2
10296
by: Nikhil Patel | last post by:
Hi all, How can I raise the Click event of the LinkButton server control in Javascript? Thanks.
7
2883
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 testing by manually starting the app from the server, that is logging into the server, and running). This app depending on available resources (txt, xml data files), starts simple exe console apps which load simple data feeds into an SQL db. In...
8
1943
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 into the database. after that is done i want to send the user to PageC, but before i do that i check a variable value. if that value is "0" then i want to raise a javascript alert telling the user they need to set some info in PageA and then...
1
1716
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 information for the title property of the img tag. The functions i wrote below are sort of working since it needs an alert() to work the slides ???
24
2508
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 finally, and painfully, fade away than another one starts up. I suggest that Python should raise warnings.RuntimeWarning (or similar?) when a function is defined with a default argument consisting of a list, dict or set. (This is not meant as an...
1
2260
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 perticular employee has to attend a new course If he is busy in the other course between these two dates. Thanks in advance
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.