Newbie Question - Copy folder prior to installation - 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!

Meilyne
Posts: 2
Joined: Sat Jul 05, 2008 4:02 pm

Newbie Question - Copy folder prior to installation

I'm very new to advanced installer ( or any installer for that matter).

I need to copy a folder containing data before installation an updated version of my application and then copy the folder back into the new installation. Unless I can set up installer to not install over that one folder.

How would I go about doing this? Thanks for any and all help on this matter.

Sue
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Newbie Question - Copy folder prior to installation

Hi Sue,

This can be done by using xcopy.exe as a custom action (this file is in the "C:\Windows\system32" folder). Here are the steps:
- go to the Custom Actions page and create a "New Attached Custom Actions"
- when prompted for the source of the custom action, select the "xcopy.exe" file
- set the "Command Line" field to something like this:

Code: Select all

<source_folder> <target_folder> /s /e /y /q /I
Here is a sample command line for the custom action:

Code: Select all

"C:\Original Folder" "C:\Temporary Folder" /s /e /y /q /I
Since you want to run this custom action before the installation updates the old package, you can schedule it under the "InstallExecuteSequence" -> "CostFinalize" standard action. Note that you can show a standard action by using the "Show Standard Action" button on the toolbar of the "Custom Actions" page.

In order to copy the folder back in the original location, you can use another custom action similar to this one. This custom action can be scheduled under "InstallExecuteSequence" -> "InstallFinalize". Also, in order to delete the temporary folder, you can use another custom action like explained in the Remove a file or a folder during installation how-to.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Meilyne
Posts: 2
Joined: Sat Jul 05, 2008 4:02 pm

Re: Newbie Question - Copy folder prior to installation

Thank you for your quick response to this. I'll give it a try.
phantomz4z
Posts: 1
Joined: Mon Nov 03, 2008 9:50 am

Re: Newbie Question - Copy folder prior to installation

Hi,

One problem using Xcopy.
If i defined a search property to look for wwwroot, the found propery value will be [x]:\inetpub\wwwroot\
Please note that Xcopy doesnt accept the last slash in the folder as an input, it must be like this to accept it and work properly :
[x]:\inetpub\wwwroot

If i added the xcopy action and appended the value of property of wwwroot as an input it will not work? please advise how to remove the last slash?

Thanks
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Newbie Question - Copy folder prior to installation

Hi,

The trailing backslash can be removed by using a custom action. Here is some sample VBScript code:

Code: Select all

folderPath = Session.Property("MY_PROP")

If Right(folderPath, 1) = "\" Then
  folderPath = Left(folderPath, Len(folderPath) - 1)

Session.Property("MY_PROP") = folderPath
In this code you can replace "MY_PROP" with the property which contains the path of the folder.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: Newbie Question - Copy folder prior to installation

phantomz4z wrote:Please note that Xcopy doesnt accept the last slash in the folder as an input, it must be like this to accept it and work properly :
[x]:\inetpub\wwwroot

If i added the xcopy action and appended the value of property of wwwroot as an input it will not work? please advise how to remove the last slash?

Thanks
You don't have to remove the last slash. You can add an asterisk to it like this:

Code: Select all

xcopy [x]:\inetpub\wwwroot\* destination
Success!

Return to “Common Problems”