Installing to another user account? - Advanced Installer Community
Codename K
Posts: 479
Joined: Fri Jan 29, 2010 3:04 pm

Installing to another user account?

Hello,

Is there a way to install (per user only) to another user account. If you are logged-in as UserA then install to UserB?

:)
K
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installing to another user account?

Hello,

In order to achieve this you can build an EXE package type and, then run the EXE package from command line under different user account. For example you ca use a command line like this:

Code: Select all

runas /user:<domain>\<username> "FolderPath\Setup.exe"
Also, if you are building an MSI package type, then in order to achieve what you want you can proceed like this:
- open a command prompt window
- run the following command line (in order to open cmd.exe under a different user account)

Code: Select all

runas /user:<domain>\<username> cmd.exe
- in the new opened command prompt window run a command line like this:

Code: Select all

msiexec /i "FolderPath\Setup.msi"
You can also take a look on the "How do I run a program from command prompt as a different user and as an admin" thread which could be useful for you.

If you have any questions let us know.

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

Re: Installing to another user account?

Hello,

Thanks for the info. Is there a way to get the list of user accounts to a dialog and select which one to install?

:D
K
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installing to another user account?

Hello,

I'm afraid we don't have predefined support for this. However, you can try to use a custom action in order to achieve what you want. For example you can create a fully fledged C# custom action which will search for all user accounts existing on a computer and add them to a combo box or list box control added on your installation dialogs. Please take a look on our "Working with Windows Installer ComboBox and ListBox controls" article.

Also, you can take a look on "How can I get a list Local Windows Users" thread which could be useful for you.

If you have any questions let us know.

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

Re: Installing to another user account?

Hello,

Thanks again. If I am installing to specific user like this how will the uninstall work? Will this be that user only? For example: I installed to UserB from UserA. If I run the installer on UserA again will this show the repair dialog or the welcome dialog?

:)
K
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installing to another user account?

Hello,
For example: I installed to UserB from UserA. If I run the installer on UserA again will this show the repair dialog or the welcome dialog?
If you are using a per-user installation type, then in this case the setup is installed only under UserB. Therefore when it will be launched under UserA the installer will run a first time install (WelcomeDlg will be displayed).

If you have any question let us know.

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

Re: Installing to another user account?

Hello,

Thanks again. I am planning to run an installer within another installer. I mean the first installer will launch the second installer attached via Custom Actions > Launch attached file. The idea here being that the second install will install to a specific user other than the current user. Can we give the command in the Command Line: like the below one,

Code: Select all

runas /user:<domain>\<username> "FolderPath\Setup.exe"
:)
K
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installing to another user account?

Hello,

In order to achieve this you can use a BAT file which will launch your "Setup.exe" under a different account. For example you can proceed like this:
- create a BAT (e.g. "run.bat") file like this:

Code: Select all

runas /user:%1 %2
- add the "run.bat" and "Setup.exe" files as temporary files to your project
- go to "Custom Actions" page and add a custom action which will populate a list box control (LISTBOX_PROP) with user accounts existing on target computer
- add a "Launch File" custom action without sequence like this:
  • File To Launch: [&run.bat]
    Command Line: "[LISTBOX_PROP]" "[&Setup.exe]"
- go to "Dialogs" page and add a list box control (LISTBOX_PROP) on a custom dialog
- on the [Next>] button add a published event like this:
  • Event: Execue custom action
    Argument: LaunchFile
- build and run your project

If you have any questions let us know.

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

Re: Installing to another user account?

I tried and got this message when the second installer starts to run after getting the cmd window to enter user password,

Image
K
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Installing to another user account?

Hello,

I'm not sure why this happens. Can you please send us the .aip (project file) to support at advancedinstaller dot com so we can investigate?

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

Re: Installing to another user account?

OK, just sent there.

:)
K

Return to “Common Problems”