Uninstall Sequence needs to rename a file back - 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!

ahinton
Posts: 7
Joined: Tue May 26, 2009 7:16 pm

Uninstall Sequence needs to rename a file back

Here is the situation

I'm writing an installer to take files that are packaged in the MSI file and overwrite the existing files that are already there.

I first was able to successfully rename the existing file to another name like backup.txt and then I copy the new file into that directory.

Now my challenge is that on uninstall what I want to do is rename that file backup.txt back to what it should be which is live.txt

Right now it removes all the files that the installer package put there but it doesn't rename the file from backup.txt to live.txt

I figure I have to write a custom Action to rename the file back and I assume I Add a Predefined Custom Action but I don't know the syntax or the script necessary to achieve the next step

So your help would be greatly appreciated.

Alan.
ahinton
Posts: 7
Joined: Tue May 26, 2009 7:16 pm

Re: Uninstall Sequence needs to rename a file back

It's ok I solved my own problem

I created a Custom Action under the Uninstall section
Used the EXE with Working Directory and path given by a Formatted" item

Then put this path "[%ComSpec]" /C REN "[APPDIR]\Backup.txt" "live.txt"

Into the Full Path line

And now things seem to be working

Is this the best way to do it ?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Uninstall Sequence needs to rename a file back

Hi,

Although you need a different custom action for each file, this is a good solution. Another approach is explained in the Preserve file on install how-to (you can easily adapt it to what you need).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SubJunk
Posts: 3
Joined: Sat Oct 23, 2010 9:42 am

Re: Uninstall Sequence needs to rename a file back

Hi, sorry for resurrecting a dead thread but I wanted to ask a question about it.
I want to do the same thing as ahinton did, but when I do that the CMD window says "Access is Denied".
It's not surprising since the files are in Program Files and UAC is active, but I wonder if there is a way to give the user a chance to elevate to allow it.

Thanks in advance for any help, and your program is working great.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Uninstall Sequence needs to rename a file back

Hello and welcome to Advanced Installer Forums,

Since you are new, I highly recommend you read our tutorials for a better understanding of how to use Advanced Installer to efficiently deploy your products.
This will also help you better understand support team's suggestions now and in the future. The simple and professional tutorials are especially important.

Make sure the custom action is run as "deferred with no impersonation" for it to have elevation privileges. Also, make sure the Install Parameters->Installation Type is set to have administrative privileges.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
SubJunk
Posts: 3
Joined: Sat Oct 23, 2010 9:42 am

Re: Uninstall Sequence needs to rename a file back

Thanks a lot, it works now
SubJunk
Posts: 3
Joined: Sat Oct 23, 2010 9:42 am

Re: Uninstall Sequence needs to rename a file back

It doesn't seem to work for other users, so I wonder how to modify this for my purposes.

My goal is to create a backup of existing files when my program is installed, then when it is uninstalled those old files go back.
Is that still the best tutorial to use for that purpose, considering that the time between backup and restore could be months?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Uninstall Sequence needs to rename a file back

Hi,

The how-to you mentioned is appropriate for what you need. You don't need to modify anything, simply add the custom actions as explained. To run the restore custom action during uninstall you can set this condition for it:

Code: Select all

REMOVE = "ALL"
This way a backup is created during install and the files are restored during uninstall.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”