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!

atexier
Posts: 3
Joined: Tue Jan 22, 2019 11:38 am

Rename folder if exist

Hello,

I’m new to Advanced Installer and try to make an installer upgrade an application.
I want to rename some folder if they exist before installing the new version.

Can someone point me to the right direction or FAQ/Guide article?

Regards,
Alexis
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Rename folder if exist

Hello Alexis and welcome to our forums,

I think that in this case you can use our predefined support for "Searches". Please have a look on the following "Search Page" article for a better understanding of our search support.

In what regards the folder renaming, you can have a look on our "Folder operations in the Files and Folders page" article.

Hope this helps.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
atexier
Posts: 3
Joined: Tue Jan 22, 2019 11:38 am

Re: Rename folder if exist

Hello Catalin,

Thanks for your quick reply.
I don’t understand how I move from the search result to the rename folder.
Something in Custom Actions?

Kind regards,
Alexis
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Rename folder if exist

Hello Alexis,

I apologize for forgetting to mention the file rename. Somehow it seems that I have missed that point.

As you have already stated, yes, that can be done through a custom action. All you want to do here can be achieved through a custom action. As for this moment, since you are new to Advanced Installer, let's try to forget the "Search" approach and try to solve your problem from a custom action only.

First of all, let me try to explain what a custom action is. Custom actions are actions entirely defined by the user. They can be executable files, dynamic linked libraries, Visual Basic scripts, JavaScript files or PowerShell script files. They can be scheduled at any time during the installation.

Before we try to implement our solution in Advanced Installer, let's see how we can achieve those said above (finding a folder and renaming it) outside of Advanced Installer. This can be done through a PowerShell Script. Here is a script which does what you want:

Code: Select all

$path = 'C:\Users\Catalin\Desktop\MyFolder'
if(Test-Path $path){
Rename-Item -Path $path -NewName "MyNewFolder"
}
Quick Explanation: The $path variable stores the path to the folder that you want to be renamed. The "Test-Path" cmdlet determines whether all elements of the path exist. It returns "True" if all elements exist and "False" if any is missing. The "Rename-Item" cmdlet changes the name of a specified item. This cmdlet does not affect the content of the item being renamed.

Now that we have developed a solution, it is time to implement it in Advanced Installer. To do so, you can proceed as it follows:

- please go to "Custom Actions" page.

- there add the "Run PowerShell inline script" predefined custom action with sequence. In order to add a custom action with sequence, simply press the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

- under "#Your code goes here." comment, add the script content mentioned above.

- in order to make this custom action run at the begin of the installation, we have to schedule it to do so. In order to achieve this, simply drag and drop your custom action before the "Searches" action group (under "Wizard Dialogs Stage").

- now that you have correctly scheduled your custom action, click on it and under "Dialogs Stage Condition" please uncheck the "Uninstall" and "Maintenance" options.

Attached to this thread you can find a sample project, for your reference, where I have implemented the solution described above.
Your Application.aip
(13.68 KiB) Downloaded 476 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
atexier
Posts: 3
Joined: Tue Jan 22, 2019 11:38 am

Re: Rename folder if exist

Hello Catalin,

And a very big thank you.
Your explanation is extremely clear.
That work as intended.

Again, thank you.

Best regards,
Alexis
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Rename folder if exist

You're always welcome, Alexis.

I am really glad I could help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”