GoGreen PC Tune-Up™
Learn More

Insta-Install™
this is how we code sign our software and ssl encrypt our websites from our affiliate partner SSL.com
MTNCOMP | List | Table

myBlog

myBlog Home

Blog


Microsoft Windows

Microsoft Windows Visual Studio elevate application to admin - two methods

by Mountain Computers Inc., Publication Date: Monday, March 28, 2022
View Count: 229, Keywords: Visual Studio, Application, Administrator Permissions, Hashtags: #VisualStudio #Application #AdministratorPermissions



one can do it one of two ways depending on your compile/build.
 
my first way was; include "setup" or "install" in the name the EXE or MSI filename. The MSI is tricky if the user does not have access to the %temp% or c:\windows\temp folder. There are posts I have written about this - the 2503 MSI installer error for Libre Office. In this case I have used both solutions below in my applications to force the elevation to admin, for example:
 
mysetup.msi ,setupMyApp.msi ,installMyApp.msi ,myApplicationSetup.exe ,SetupMyApp.exe, installMyProgram.exe
 
my second way which I don't use too much is ; in Visual Studio | Project | Application | View Windows Settings option to elevate the application and take this part out and swap with the existing askInvoker line of code
 
to elevate an application either as an EXE or MSI, just swap the lines of code from the commented section to be
 
requestedExecutionLevel level='asInvoker' ... with requestedExecutionLevel level='requireAdministrator' ...
 
swap the lines of code from the commented section of asInvoker to requireAdministrator, keep the lines of code in case you need to switch them back...
 

 
 
REF:  https://www.reddit.com/r/VisualStudio/comments/tpy7ph/visual_studio_setup_project_prompt_for_admin/
 
more to come...

if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.

© 2022 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.