I think you've already diagnosed the issue, and enumerated your available options. To my mind the best option is to use runas
to create a new elevated process, and get that process to do the work.
The other process need not be a different executable it could be your existing executable started with particular command line arguments. Once you have another process running elevated, you can certainly use cmd
with redirected stdin/stdout to do the work. However, why use net stop/start
rather than the service API? And can you do the .config
file modification without starting a separate process?