Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Request administrator privileges based on the type of installation

Hello!

It is necessary to create an installer for the application, but I have encountered some difficulties. Here is a brief description: the installer should be able to install the application or run the application from the temporary folder. During installation, the Windows service will be created and the program will be registered in the list of windows programs. If the option "run the program" is selected - it is simply unpacked into a temporary directory and launched. Important: to run the installer, you do not need administrator rights.
But there are conditions, the solutions of which I did not find:
1. If user has chosen to run the program without installation, then the administrator's rights should not be required at all. (a temporary folder of windows is available to all users)
2. If the user has selected the option "install the program", then it is necessary that the installer ask for administrator rights (needed to install the windows service)
Maybe I should somehow restart the installer at the stage of choosing the installation, but already with the requirement of administrator rights? But how?
If you have examples of an installer with a choice of installing or running the program, I'll be glad to see it.
Thank you.
Advanced Installer - Enterprise version.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Request administrator privileges based on the type of installation

Hello,

You should be able to achieve this by using the "Elevation Shield" attribute of a push button control from your dialogs. For instance you can proceed like this:

1. on a dialog of your dialogs chain add two {Next] buttons: one button with the "Elevation Shield" set to false and the other with the flag set to true
2. add control conditions on the above buttons to show and hide depending on the state of your "run the program" and "install the program" check boxes

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Re: Request administrator privileges based on the type of installation

Thanks for the help with the "Elevation Shield" attribute!
But I have another question. As I described above - the installer should be able to install both, and just run the application without installation.
I decided this by creating two Feature:
1 InstallFeature - the standard installation of the application.
2 RunFeature - just unpacking the files into a temporary directory and launching the application.

When the "Install Application" option is selected, it must register with the Windows Installer. When the "Run application" option is selected, it must not be registered. As I understand it is not possible to switch on and off the "Register product with Windows Installer" option based on the value of a public property. Is there another way out of this situation?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Request administrator privileges based on the type of installation

You are welcome.

Yes, unfortunately it is not possible to control the "Register product with Windows Installer" option at install time. As a workaround solution you can create three setup projects:

1. one project using the "Register product with Windows Installer" option
2. a second one having the "Register product with Windows Installer" option disabled
3. and a third one wrapping up the first two ones as feature-based prerequisites; then in the third wrapper project you can create a custom feature selection dialog

Hope this helps.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Re: Request administrator privileges based on the type of installation

Thanks, Daniel! I took your advice and everything works great!
But when i run installer (wrapper) and select the action (install or run) opens an additional process and user see 2 windows (one window from wrapper installer and second is from feature-based prerequisites).
I tried to call custom action to close the process of the first installer by its name, but the user can rename it and this will not help.
Is there a way to just exit from the installer w/o any dialog after the choice of the action (install or run app)?
Or is there a property that holds the name of the exe file?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Request administrator privileges based on the type of installation

Hello,

I think the easiest way to avoid the duplicate UI stage of the setup packages will be to launch the prerequisites setup silently. Just go to "Prerequisites" page, select your prerequisite package, go to "Setup Files" tab and in the "Install Command Lines" fields add a silent install command line:

Code: Select all

/qn
Also, to get the EXE setup path you can access the value of "SETUPEXEDIR" property.

Hope this helps.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Re: Request administrator privileges based on the type of installation

Hello again. And again, I have a question )
Since I run prerequisites with a silent installation I tranfer parameters in the command line (such as APPDIR). And I also want to manage creating shortcuts in the start menu and trying to make it by transmitting 0 or 1 in AI_START MENU_SH, but it's not working. Can I do it this way?
Also thank you very much , Daniel, for your help!
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Request administrator privileges based on the type of installation

Hello,

If the predefined "ShortcutsDlg" dialog is added to your dialogs chain, then it should work to set the AI_STARTMENU_SH property by command line.

However, please note that when you want to install the start menu shortcut you should use a command line like this:

Code: Select all

msiexec /i setup.msi AI_STARTMENU_SH=1
but when you do not need it to be installed you should set the AI_STARTMENU_SH property to empty string like this:

Code: Select all

msiexec /i setup.msi AI_STARTMENU_SH=""
Let us know if this is still of no help.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Re: Request administrator privileges based on the type of installation

I think, i found a bug with a command line for prerequisites in Advanced installer.
I tryed to use command line like

Code: Select all

msiexec /i setup.msi AI_STARTMENU_SH="" AI_DESKTOP_SH=""
Screenshot:
http://i105.fastpic.ru/big/2018/0629/6f ... 79a26f.jpg
But install even do not start because of error in command line.

Then i tryed to use command line like just

Code: Select all

AI_STARTMENU_SH="" AI_DESKTOP_SH=""
Screeenshot:
http://i104.fastpic.ru/big/2018/0629/55 ... 9e7b55.jpg
And here is parameters, that was transfered (screenshot):
http://i104.fastpic.ru/big/2018/0629/fe ... 1e06fe.jpg
I think, that Advanced installer cant work with empty parameters and as you can see on screenshot it tranferes text, but not empty value.
P.S.
If i use the same run commands in windows command line - all works fine.
Roman
Posts: 12
Joined: Mon Jan 15, 2018 3:48 pm

Re: Request administrator privileges based on the type of installation

Still have the same problem in version 15.0.
Catalin
Posts: 6584
Joined: Wed Jun 13, 2018 7:49 am

Re: Request administrator privileges based on the type of installation

Hello,
I tryed to use command line like

Code: Select all

msiexec /i setup.msi AI_STARTMENU_SH="" AI_DESKTOP_SH=""
You don't have to append the msiexec /i command line, because Advanced Installed automatically does that.
Then i tryed to use command line like just

Code: Select all

AI_STARTMENU_SH="" AI_DESKTOP_SH=""
I have tested this and indeed the problem reproduced. It seems to be an issue with Advanced Installer.

We will update this thread as soon as there will be a fix for this problem.

Regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Request administrator privileges based on the type of installation

Hello,

This was fixed in version 15.2 of Advanced Installer released on August 13th, 2018.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”