We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

rohitgarg20
Posts: 31
Joined: Thu Mar 13, 2014 6:31 am

Set AppDir at runtime depending on Search and user type

Hi

I am building an installer for our software.
I have two requirements for it:

1) Install in Program Files Directory if "All Users" Mode is selected else install in Local AppData folder if For current user.
2) I have two properties in Searches page. I would like to install Application in Program Files x86 folder if one property is found, otherwise install in Program Files 64 folder.

So, basically if "All Users" mode, install application in proper Program Files folder depending on the property in Searches page.

So far I have tried following:
Set Application Folder = [AppData][ProductName] or [ProgramFilesFolder][ProductName] or [AI_ProgramFiles]\[ProductName]

and make a custom action which does something like:
////Script Sample
AllUsers = Session.Property("AllUsers")
If AllUsers = false
Session.Property("AppDir") = [LocalAppDataFolder][ProductName]
end if

If AllUsers = true and Install_32 then
Session.Property("AppDir") = [ProgramFilesFolder][ProductName]
end if

If AllUsers = true and Install_64 then
Session.Property("AppDir") = [ProgramFiles64Folder][ProductName]
end if
///////

But the path is not setting as desired after user chooses the installation type (i.e. All users/Current User) and installation path always sets to one specified in Application Folder text box in Install parameters page.

So, kindly give valuable suggestion so I can make it work.

Thanks & Regards
Rohit Garg
rohit.aggrawal90@gmail.com
Last edited by rohitgarg20 on Wed Jun 18, 2014 11:37 am, edited 1 time in total.
R
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set AppDir at runtime depending on Search and user type

Hello Rohit,

Please note that you can implement the desired behavior by using the predefined InstallTypeDlg dialog.
This dialog will allow the user to choose where the application will be installed:
  • Local User - The application will be available only for the user who runs the installation package. This is the only option available if the user has no administrator privileges.
  • All Users - The application will be available for all users. For this type of installation, a user with administrator privileges is required.
Also, in Install Parameters Page set the install type to: Per-machine if user is administrator, per-user otherwise. So, the application will be installed "Per-machine" if the user has administrative rights and "Per-user" otherwise.

Please take a look on the How do I make the package install per-user or per-machine? article with related information for hints and guidance.

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rohitgarg20
Posts: 31
Joined: Thu Mar 13, 2014 6:31 am

Re: Set AppDir at runtime depending on Search and user type

Hi Dan

I am aware of the InstallTyp dialog. I have already added it in dialogs. The thing is that Whether the user selects "current user" or "All User" in InstallTyp dialog, the installation path is not changed i.e it remains same.

What i want is, If User selects "Current User" the install path remains LocalAppDataFolder and if he selects "All Users", the install path should be Program Files x86/program Files(64) depending on the search condition in searches page.


Kindly provide suggestions on how to achieve that.

Thanks and Regards,
Rohit Garg
R
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set AppDir at runtime depending on Search and user type

Hi Rohit,

Can you please make sure that you have selected the Per-machine if user is administrator, per-user otherwise option for the Installation Type from the Install Parameters page?

If the behavior still persist, can you please send me your .AIP(project file) to support at advancedinstaller dot com so I can investigate this?

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rohitgarg20
Posts: 31
Joined: Thu Mar 13, 2014 6:31 am

Re: Set AppDir at runtime depending on Search and user type

Hi Dan

Yes i have made this change also. I have just sent the file on the specified email.

Kindly check and provide suggestions accordingly.

Thanks & Regards,
Rohit Garg
R
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set AppDir at runtime depending on Search and user type

Hi Rohit,

This is happening because you are not using the AI_UserProgramFiles property in the Application Folder field from the Install Parameters page.
The "AI_UserProgramFiles" property will be referenced in the application folder path and it is set at install time when the installation type is "Per Machine/User" to one of the following values: ProgramFilesFolder if the user has administrative rights, LocalAppDataFolder otherwise.

So, can you please make this change and see if the behavior still persist?

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rohitgarg20
Posts: 31
Joined: Thu Mar 13, 2014 6:31 am

Re: Set AppDir at runtime depending on Search and user type

Hi Dan

Thanks for suggesting about AI_UserProgramFiles. I have used this before and it resolves to corresponding Program Files directory depending on the bitness of the application executable.

What i want is to set installation path to ProgramFiles32 or ProgramFiles64 depending on the INSTALL_32/INSTALL_64 search condition on search page.

It will be like:

Code: Select all

If Mode = LocalUser then
Session.Property("APPDIR") = LocalAppDataFolder (which is happening correctly)
end if

if Mode = AllUsers and INSTALL_32 = true then
Session.Property("APPDIR") = ProgramFiles(x86)
end if

if Mode = AllUsers and INSTALL_64 = true then
Session.Property("APPDIR") = ProgramFiles(x64)
end if
I have made a VB custom action for this and moved the function just after the installtyp dialog and tried to Set APPDIR as mentioned above in code.
But the APPDIR is not set according to custom action script. I don't know why.

Kindly put light on this.

Thanks & Regards,
Rohit Garg
R
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set AppDir at runtime depending on Search and user type

Hi Rohit,
What i want is to set installation path to ProgramFiles32 or ProgramFiles64 depending on the INSTALL_32/INSTALL_64 search condition on search page.
Please keep in mind that a 32-bit installation package, on 64-bit machines, cannot install resources into 64-bit locations (i.e. "Program Files" folder).

Although 32-bit package can be installed on 64-bit platforms, the ProgramFiles64Folder, CommonFiles64Folder and System64Folder are resolved to the redirected locations, that is why you need a 64-bit package in order to access the real system paths on a 64-bit platform.
Their 32-bit counterparts are resolved to redirected locations as follows:
  • ProgramFilesFolder - C:\Program Files (x86)\
  • CommonFilesFolder - C:\Program Files (x86)\Common Files\
  • SystemFolder - C:\Windows\SysWOW64\
This is the default behavior for Windows Installer.

In order to implement your scenario, you can select the Mixed 32/64-bit matching the platform option for the package type.
This package runs as a 32-bit package on 32-bit systems and as a 64-bit package on x64 systems. It allows you to have a single installation package that will install on both platform types (32-bit and 64-bit platforms) and can install files or registry in the real system paths regardless of the platform.

When the "Mixed 32/64-bit matching the platform" package type is selected in the Install Parameters page, then the wizard will launch and will guide you step by step through every stage required to organize your “Mixed 32/64-bit matching the platform” package, as it can be seen in the below image:

Here is an article which may be useful to you: How do I create a package that will be installed like a 64-bit package on 64-bit platforms and as 32-bit package on 32-bit platforms ?.
This easy approach is to use the Mixed 32/64-bit matching the platform wizard.

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rohitgarg20
Posts: 31
Joined: Thu Mar 13, 2014 6:31 am

Re: Set AppDir at runtime depending on Search and user type

Hi Dan

Thanks for the information. That really helped me a lot.

Thanks & Regards,
Rohit Garg
R
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set AppDir at runtime depending on Search and user type

You're welcome Rohit,

If you have other questions, please let us know.

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

Return to “Building Installers”