If you don't mind UAC kicking in (but I fear that you do), then you can simply do, for example:
HINSTANCE hInst = ShellExecuteW (NULL, L"runas",
L"notepad.exe", NULL, NULL, SW_SHOWDEFAULT);
Check the documentation for values returned in hInst
. Sorry the example is in C++ but I'm sure you can translate.
If you want to circumvent UAC then you must indeed launch your application from a service in order to have it run elevated. Sample code here, again in C++, sorry, and it could use a little polishing up but it certainly works. I assume you want to run the process in the context of the currently logged-in user as that code does. Please vote that answer up (or this one, or both) if it helps U.
Edit: (as the OP is still evidently struggling with this).
You know what? I could give you chapter and verse on how to solve this problem but I'm not going to, because you would just build one big, huge security loophole when your software was installed. That too is soluble, but would you actually bother?
Anyway, put yourself in your users' shoes for a moment. How do you think they will feel when a program starts doing things that can normally only be done by a program running as Administrator without first displaying the expected UAC prompt? If it was me, I would freak out.
So no, just use the ShellExecute
trick I first recommended and leave it at that. It's more than good enough.