The task is widespread, but I’m not satisfied with the solutions I’ve found so far.
The program must work on the background, regularly scan the system for the state change and, on some conditions, show notifying popup windows to users. The program runs under Windows 7.
There are two nuances. First, it needs elevated privileges (highest level, run as administrator, there is a mess of terminology in Windows) to scan for some protected system information. Second, it must work for all users which have administrative rights.
Here’s the list of typical solutions and reasons why they don’t suit.
The task looks very common, but the solutions are complicated. Do I misunderstand something? Are there easier ways?
PS: I've seen this topic Process with administrative privileges run on user logon, but wonder if there are less complicated ways.
UPDATE
I found out that solutions with windows services also don't work for my task. I need to access user's personal certificate store. Service runs under one account and needs to access certificates of another. I haven't found how to do this with .Net cryptography API and guess it's not possible due to security policy. I posted the solution I finally came up with as the answer to this question.
You'll need a service to do the "dirty work" (i.e. where admin rights are required). Add to that an app that interfaces with the user.
Services are not hard to debug - just connect to the running process in Visual Studio.
Depending on what you are trying to accomplish, you can bypass UAC using a well know security bug to run your elevated code. I wouldn't recommend this for any type of commercial use, but in quick and dirty instances, it might be just the ticket.
http://www.pretentiousname.com/misc/win7_uac_whitelist2.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With