javaquests
Posts: 13
Joined: Tue Dec 07, 2010 2:50 pm

How to dynamically set users directory path

Hi,

I need to point my installation to users directory path. How do i dynamically set the users directory in install paramter property?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to dynamically set users directory path

Hi,

Please note that the "Application Folder" combo in "Install Parameters" page contains multiple values. You can try selecting another one which better suits your needs. If none of the predefined values help you, you can define a custom path. If you don't know what path to set, can you please give me more details about the path you want to use?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
javaquests
Posts: 13
Joined: Tue Dec 07, 2010 2:50 pm

Re: How to dynamically set users directory path

I need to point my installation directly under users directory. for eg: a user named "abc" installs the program, I want the installation path to point to "C:\Users\abc\" directory. I could not find one in application directory of this type. please let me know how to write custom parameter to dynamically know the users directory and point to that location.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to dynamically set users directory path

Hi,

Unfortunately Windows Installer doesn't support this path directly. However, you can try this approach:
- set your default installation folder to:

Code: Select all

[DesktopFolder]
- in Custom Actions page create a custom action which trims the "Desktop" string from APPDIR property value
- after being trimmed the value should be something like this:

Code: Select all

C:\Users\<username>
- set this value back in APPDIR property
- schedule this custom action under "InstallUISequence" -> "Begin"
- share it with "InstallExecuteSequence" -> "Begin" by dragging it while SHIFT key is pressed
- make sure it uses the "Execute only once if present in both sequence tables" option in Custom Action Properties pane

This way the installation path starts with the Desktop path, but it's modified by your custom action to the user account root folder. To access installer properties you can use MsiGetProperty() and MsiSetProperty() in Win32 DLLs or Session.Property() in VBScript.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
javaquests
Posts: 13
Joined: Tue Dec 07, 2010 2:50 pm

Re: How to dynamically set users directory path

I changed the app directory path to DesktopFolder. when i click on custom action from tool bar it opens a window to choose the custom action type. in my case which one should be selecting? Can be more more specific on how to create custom action to trim desktop?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to dynamically set users directory path

Hi,

First you need to create a C++ DLL or a VBScript which gets the APPDIR property value, modifies it and sets it back in APPDIR. For a sample C++ DLL custom action please read the Serial Number Validation DLL article. After creating the custom action file, you can add it as a "New Attached Custom Action" in "Custom Actions" page.

I'm afraid that we don't have sample code which trims a folder path.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
javaquests
Posts: 13
Joined: Tue Dec 07, 2010 2:50 pm

Re: How to dynamically set users directory path

Thank you so much, i tried setting the custom actions and also doing other settings and is now getting the installation path of my choice.

Return to “Feature Requests”