I am currently just calling my own program in a new process with:
MyProcessStartInfo.Verb = "runas";
MyProcessStartInfo.Arguments = "MyFlag";
And when the process starts I check for the flag. If it’s there – I just execute the method and Close();
But I would rather do something more minimalistic if it could be done simply. Is that possible?
EDIT: Using Vista and Windows7.
You can not elevate a running process. It’s simply not possible. You are doing it the correct way, by spawning another process with elevated priviledges. There is no other way.
You could create a separate application executable that has your method in it, then you would not need to restart your application. You would only need to start that other process.