You encounter problems when you use to install the service. Code fragment provided:
It runs successfully under the promotion command prompt, but fails when calling in your application.
Process.Start
Solution: Promotion of permissions InstallUtil.exe
ProcessStartInfo startInfo = new ProcessStartInfo(m_strInstallUtil, strExePath); System.Diagnostics.Process.Start(startInfo);
attribute of the
object to "runas":This command indicates that Windows executes the process with the administrator's permissions to simulate the effect of calling its effect through the "Run as an administrator" option in the resource manager.
UAC Precautions startInfo
Verb
startInfo.UseShellExecute = true; startInfo.Verb = "runas";
alternative: embedded the list
To avoid UAC prompts, consider increasing the authority by embedding the list. This will display a UAC prompt at the time of the application and automatically increase the permissions of all its sub -processes, thereby no additional prompts.
The above is the detailed content of How Can I Programmatically Elevate Process Privileges in C# to Run InstallUtil.exe?. For more information, please follow other related articles on the PHP Chinese website!