Question

I have an application that does a loop which starts some processes programmatically one by one. My app itself runs under a standard user, but I need to run only those processes as admin so I can install them.

To achieve this, I use the 4th response from this thread

My two questions are:

  1. is that code which is pointed in the above response, supposed to ensure that the process automatically runs as admin, or that the user is shown a dialog where he chooses whether to run as admin or not? I am confused by what this code is supposed to do.

  2. Also, in case a dialog is supposed to be given to the user - how can the app be coded, so that the first user option is remembered in my loop for the next processes started with the verb "runas" ? So basically to store somewhere the user option (run as admin or not) for the other processes.

Thank you in advance

Was it helpful?

Solution

First question: It is how to start an elevated process from a non-elevated one.

Second question: there isn't -- or at least shouldn't! -- be any way for a non-elevated process to elevate anything without a user prompt. The best solution for your program is either to start it off with admin rights, or to use the first elevation request as an opportunity to restart with them (using the technique you linked to).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top