Search code examples
cwindowsgccadmin

Can i compile a C program using GCC which automatically asks for admin rights?


I'd like to compile a program which simply kills a task after a previously executed program has quit. This doesn't work without admin privileges.

I'm aware that you can choose "Run program as administrator" from the compatibility tab in the properties of the executable, but if possible I'd like to avoid the necessarity of doing so when distributing the program.

I'm using GCC 4.8.1 on Windows 8.1 to compile.

Edit: About 5 years later I'd propably have gone with system("tskill <processname>") in this situation, since it doesn't require admin rights on user processes. Alternatively some hack using runas/vbscript.


Solution

  • It looks like this may have already been figured out - you might want to look here and see if any of this helps: Embed manifest file to require administrator execution level with mingw32

    From what I can tell by reading that question, it seems that requiring administrator rights to open an application is not something you have to do in code, but instead involves the resources in the compiled executable. That is not something I am too familiar with, but it looks like the link I gave can get you started down the right path.