Click here to Skip to main content
15,941,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Helllllooo....
I just want to create a event whenever user runs an application...
for thats what I've got from here...

C#
public partial class Form1 : Form
    {
        public System.Management.ManagementEventWatcher mgmtWtch;
 
        public Form1()
        {
            InitializeComponent();
            mgmtWtch = new System.Management.ManagementEventWatcher("Select * From Win32_ProcessStartTrace");
            mgmtWtch.EventArrived += new System.Management.EventArrivedEventHandler(mgmtWtch_EventArrived);
            mgmtWtch.Start();
        }
 
        private void mgmtWtch_EventArrived(object sender, System.Management.EventArrivedEventArgs e)
        {
            MessageBox.Show((string)e.NewEvent["ProcessName"]);
        }       
    }


which is working fine in 32bit windows but I didn't work on 64 bit window gives an exception of "Access Denied"
thanks
Posted
Comments
Sergey Alexandrovich Kryukov 18-Sep-11 17:54pm    
What are the 32-bit and 64-bit systems you used?
--SA

1 solution

Most likely your 64-bit system is Windows 7 (Vista?) where you have to run the application with elevated privileges. Logging the system in as administrator is not enough, use "Run this Program as an Administrator". You can create a shortcut "*.lnk" file to run your application requesting elevated privileges.

See this article for more detail: http://technet.microsoft.com/en-us/magazine/ff431742.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900