none
How can I configure a Visual C++ project to always run as administrator?

    Question

  • Hi,

    I have a solution with an INSTALL project that needs to run as administrator because it needs permission to create certain directories. How can I set this up in the VC project?

    Regards,

    Juan


    Juan Dent

    Wednesday, May 25, 2016 9:54 PM

Answers

  • Hi Juan,

    Thanks for your friendly response.

    Actually this forum is to discuss the VS IDE, if this issue is not related to the 2 options as my previous reply, maybe the VS General is not the correct forum for this issue.

    To help you find a more appropriate forum, I need to make this issue clearly.

    >>I actually have a VStudio solution and projects generated by CMake and one of the projects has a post build action to install using cmake command line.

    Do you mean that you want to run the setup file as the admin using the CMake command line? If so, my understanding is that it would be related to "how to use this CMake command line", it is not the VS IDE usage issue, am I right?

    As far as I know, the CMake has his own support site, if the real issue would be related to the CMake, you could select the support way here:

    https://cmake.org/services/

    So we could know that whether the CMake could run a setup project as the admin or others.

    If I have misunderstood this issue, please feel free to let me know.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 27, 2016 8:51 AM
    Moderator

All replies

  • Hi Juan,

    How did you create the install project, clickOnce or installshield?

    Maybe I misunderstood this issue, you said that you want to run the project as the admin, do you mean that you want to run the setup project(like setup.exe) as the admin using mouse click or open the project source code using the VS IDE?

    (1)If you want to open the project as the admin, just open your VS as the admin, and then open the project.

    (2)But if you mean that you want to install the setup project in your local machine as the admin, maybe you could refer to the following documents:

    http://www.codeproject.com/Articles/660204/Running-as-Administrator-with-Click-Once-Applicati

    https://social.msdn.microsoft.com/Forums/windows/en-US/1e5e8b1a-6cd2-4339-acdf-e10006865506/how-to-force-visual-studio-setup-project-to-require-admin-rights-at-installation?forum=winformssetup

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 26, 2016 8:17 AM
    Moderator
  • Hi,

    thanks for your response. However, my situation is not covered by your 2 options. I actually have a VStudio solution and projects generated by CMake and one of the projects has a post build action to install using cmake command line. I found I could force cmake to always run as administrator but that is perhaps too much power and could be potentially unsafe.

    That aside - because I got it to work -- I still have essentially the same question:

    Is there was a way to tell a native C++ project to run as admin??

    Thanks,

    Juan


    Juan Dent

    Thursday, May 26, 2016 5:05 PM
  • Hi Juan,

    Thanks for your friendly response.

    Actually this forum is to discuss the VS IDE, if this issue is not related to the 2 options as my previous reply, maybe the VS General is not the correct forum for this issue.

    To help you find a more appropriate forum, I need to make this issue clearly.

    >>I actually have a VStudio solution and projects generated by CMake and one of the projects has a post build action to install using cmake command line.

    Do you mean that you want to run the setup file as the admin using the CMake command line? If so, my understanding is that it would be related to "how to use this CMake command line", it is not the VS IDE usage issue, am I right?

    As far as I know, the CMake has his own support site, if the real issue would be related to the CMake, you could select the support way here:

    https://cmake.org/services/

    So we could know that whether the CMake could run a setup project as the admin or others.

    If I have misunderstood this issue, please feel free to let me know.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 27, 2016 8:51 AM
    Moderator