简体   繁体   中英

Running Elevated on Startup & Inter Process Communication

I am building a program that logs 3D processes in the background. Some of them are running as administrator and I need to run elevated to capture those. I am using psapi EnumProcesses with p/invoke. My question now is: how do I architect this to have the program:

  • start on user login
  • capture processes with elevated rights
  • Have UI and TaskIcon present
  • Able to restart / shutdown my program

I looked at TaskScheduler solutions but there seem to be issues with launching a UI and the TaskBar icon might not show up, so that seems to be no solution, at least in the way suggested.

I have seen people recommend a separate process to run as task / service and then communicate with it. If this is a better and recommended solution, what is the recommended way to communicate with the other process in C#? I have seen people recommend named pipes and RPC.

So in summary, my question is, how do I architecture this the proper ".NET (4.6) / C# on Windows 10" way?

Some ideas:
Start the program after user login:
You should explore windows Startup folder or registry HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
capture processes with elevated rights
Check this ;
UI and TaskIcon/Able to restart / shutdown my program
I would go for an UI application that starts in the systray and communicates with the Process Monitor using WCF for more complex data migration or EventWaitHandle if you just need signal migration.

As mentioned before, I would go for 2 applications: 1 acting as your monitor service (UI-less) and a client application with UI. The communication between these processes depends greatly on your needs, but WCF might be a good choice for complex data or EventWaitHandle for just sending/receiving signals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM