Is there a way to make the installer run as administrator or not from command-line? - Advanced Installer Community
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Is there a way to make the installer run as administrator or not from command-line?

Hello,

I have set the installer to run as per-machine if user is administrator, per-user otherwise. This is OK if the user is administrator. But for the standard user it still tries to run as administrator. Because it is showing regular program files folder location instead if local app data location.

Is there a way to make the installer run as administrator or not from command-line?

:?:
K
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,

The only way to run your setup (MSI/EXE) as administrator from command line is by opening the command shell elevated. By doing so, your setup will inherit the elevation from the command shell.

If you were asking about a command that will either run your setup as administrator or not, I am afraid that there isn't any command which can do that.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,

Will launching the installer after Finish Execution from Advanced Installer custom action as administrator work?

Also I want the installer to install for all users if run as administrator. Otherwise only to the current user. The install folder location needs to changed accordingly. But per-machine if user is administrator, per-user otherwise option still tries to install for all users when the user is not administrator.
K
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,
Will launching the installer after Finish Execution from Advanced Installer custom action as administrator work?
This can be achieved through a "LaunchFile" custom action. All you have to do is to check the "Run as administrator" option.
Also I want the installer to install for all users if run as administrator. Otherwise only to the current user. The install folder location needs to changed accordingly. But per-machine if user is administrator, per-user otherwise option still tries to install for all users when the user is not administrator.
You are right. That option is a bit "tricky". It was created to work with our "InstallType" dialog. The "InstallType" dialog will let the user choose whether he wants to install for everybody using the machine (per-machine) or only for him (per-user).

In order to add this dialog to your project, all you have to do is to go to "Dialogs" page --> click on "WelcomeDlg" --> press on the "Add Dialog" button from the toolbar and then select "InstallType" dialog.

Also, I have forwarded this to our Technical Writing team and we will try to update the documentation in what regards this option, so it will not longer create confusion between our users. Thank you for bringing this to our attention.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Re: Is there a way to make the installer run as administrator or not from command-line?

Thanks for your help.

I like to point out that setting the installer to Per-user Only sets the installation folder location to,

Code: Select all

[AppDataFolder][Manufacturer]\[ProductName]
But Extract location in Build > Bootstrapper Options also goes to the same folder location,

Code: Select all

[AppDataFolder][|Manufacturer]\[|ProductName] [|ProductVersion]\install
It does go to the [|ProductName] [|ProductVersion]\install, but this might create conflicts when the program being installed as per user.
K
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,

Thank you for your followup on this.
... but this might create conflicts when the program being installed as per user.
I am not aware of any conflicts that could be generated by the extract location of the Bootstrapper. Could you please give me a step by step test case which I can follow in order to generate such a conflict?

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Re: Is there a way to make the installer run as administrator or not from command-line?

For example,

Company Name: MyCompany
Program Name: MyProgram

The installers uses these folders,

Code: Select all

[AppDataFolder][Manufacturer]\[ProductName] = C:\Users\UserAccountName\AppData\Roaming\MyCompany\MyProgram

[AppDataFolder][|Manufacturer]\[|ProductName] [|ProductVersion]\install = C:\Users\UserAccountName\AppData\Roaming\MyCompany\MyProgram 1.0.0\install
The MyCompany folder has two sub-folders,
  • MyProgram
  • MyProgram 1.0.0
The installer extracting the files to the MyProgram 1.0.0 folder inside MyCompany folder by default might not be a good idea if the installer is set as Per-user. It would be a good idea to use another location by default to extract the files.

What would happen if the user wants his program folder to have the version number? What if the user gives the installation folder location as,

Code: Select all

[AppDataFolder][|Manufacturer]\[|ProductName] [|ProductVersion]
There will be another folder from the extracted installer files called install inside. If the user's program also has the same folder name with program related files, this might create conflicts.
K
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,

I am not sure how much of an impact this has as the extraction location can be easily configured from within the project. If the install type will be of "Per-user", you can change the extract location to another path.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Re: Is there a way to make the installer run as administrator or not from command-line?

I just thought to inform this to you that the folders are similar. That's all.

:)
K
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Is there a way to make the installer run as administrator or not from command-line?

Hello,

I understand.

Thanks for bringing this to our attention.

:)

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”