How to copy a file to %userprofile% - Advanced Installer Community

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!

Gary
Posts: 11
Joined: Tue Nov 03, 2009 8:58 pm

How to copy a file to %userprofile%

Hi,

I'm wondering if I'm going down the right rabbit hole.

I need to install a file to the directory referenced by the %userprofile% environment variable.

Is there a way to do this?

I have a .bat file that can do this that I could launch after the windows installer finishes, I think I can figure out how to do that, but it would seem cleaner if the installer could copy the file directly there.

Follow up:

I thought I sew something where I could copy a file to a folder named by a custom property and that I could set the value of the property from an environment variable. But now I can't find that. Sheesh.

This software has a lot of options and I'm getting lost in them.

Any pointers?

Gary
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to copy a file to %userprofile%

Hi Gary and welcome to Advanced Installer Forums,

The option you are referring to is called a Property-based Folder. Our guide explains its usage. You could base it on an environment variable but care is recommended. This is because this particular environment variable (%userprofile%) differs from user to user, obviously. Hence, should your package run elevated, the install process would run under the local SYSTEM account and the %userprofile% environment variable would be the one in the SYSTEM's context, thus evaluating to an unwanted path.

The way to go around this is to save %userprofile%'s value to a property at the very beginning of the install process, then use that property with a property-based folder. Attached is a sample implementation of this behavior.

Regards,
Gabriel
Attachments
test.zip
(2.22 KiB) Downloaded 812 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Gary
Posts: 11
Joined: Tue Nov 03, 2009 8:58 pm

Re: How to copy a file to %userprofile%

Hi,

Thanks for including the sample.

I notice that it's a bit different from the Guide, and when I tried it the Guide way it didn't work.

I'm going back and redoing it according to your sample.

Gary
Gary
Posts: 11
Joined: Tue Nov 03, 2009 8:58 pm

Re: How to copy a file to %userprofile%

HI,

Ok, it's working now and even uninstalls.

Now, I have two other questions I'll put in a new thread.

Gary

Return to “Common Problems”