ruck64
Posts: 57
Joined: Wed Jul 24, 2019 8:46 pm

Grant CMD with admin

Current process:
- Run Installer
- Grant admin privileges
- Grant command prompt privileges for custom action
- Install complete

Desired process:
- Run Installer
- Grant admin privileges
- Install complete

Question is: How do i get a custom action and what it does to maintain the admin privileges granted to the installer?

This same issue occurs upon uninstall. The custom action runs a batch file
Install: Create and start service
Uninstall: Stop and remove service
Catalin
Posts: 6598
Joined: Wed Jun 13, 2018 7:49 am

Re: Grant CMD with admin

Hello,

In order to achieve this, you can simply go to "Install Parameters" page and check the "Run as administrator" option. This way, the elevated privileges will be inherited by the "LaunchFile" custom action and it will not longer prompt you to provide them.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ruck64
Posts: 57
Joined: Wed Jul 24, 2019 8:46 pm

Re: Grant CMD with admin

Thank you, Though I had already attempted to do that but it fails to start the service.
So I changed my stuff around so that I would only have to launch one batch file.
Though now I have to give it admin access three times. Im using NSSM to create and start my service. So nssm asks for permission twice to be used. Which has replace the once for the command prompt. I will continue to see what I can do to make adjustments to this. Though if you know of another thread that solves this or a solution I would love to hear it.
Catalin
Posts: 6598
Joined: Wed Jun 13, 2018 7:49 am

Re: Grant CMD with admin

Hello,
Im using NSSM to create and start my service
I am wondering why are you using a third-party application to create and start your service. Have you tried following our "How to install a service" article and it did not work?
Though I had already attempted to do that but it fails to start the service.
Were you trying to start your service through the .BAT file? If you checked the "Run as administrator" option from the "Install Parameters" page, then the .BAT file should be run elevated, as it inherits the elevated permissions from its father process (the main installer). I have just done a test and everything is working as expected. Please see the screenshot below:
Capture.PNG
Capture.PNG (58.24 KiB) Viewed 4482 times
The setup (Your Application.exe) is launched elevated and the EXE (sample.exe) that I am launching through a "LaunchFile" custom action is also launched elevated, without any additional prompts.
Though if you know of another thread that solves this or a solution I would love to hear it.
I am afraid I am not aware of any other solutions. However, if you would like, you can send me the following resources:

- the .AIP file used to build the project

- a download link for the project

by e-mail at support at advancedinstaller dot com so I can further investigate this.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ruck64
Posts: 57
Joined: Wed Jul 24, 2019 8:46 pm

Re: Grant CMD with admin

So I think I recall the reason why I stopped using your built in method. And here's whats basically happening
I have it set to per-machine only(fails if.....)
32 bit build of MSI.
My exe as a service its name and paramters
So I build and start the install.
It asks for admin
I grant admin
It starts going
When its tries to start the service it states "Service could not be installed verify that you have sufficient privileges to install system services.

I have also tried having it run as admin but it creates an exe, so I change it back to MSI and it still fails.
ruck64
Posts: 57
Joined: Wed Jul 24, 2019 8:46 pm

Re: Grant CMD with admin

I just sent an email.

Return to “Common Problems”