PDA

View Full Version : Reame file after install


mike54721
11-16-2007, 09:01 AM
I need to rename a file after (or before) installing it. This file is a main file and is in the archive and also gets shortcuts (quick launch, start menu).

I do it like this right now:
IFileRenamed = SessionVar.Expand("%AppFolder%").."\\IDemo-"..PrepINum()..".exe";
File.Rename(SessionVar.Expand("%AppFolder%").."\\IDemo.exe", IFileRenamed);

I also added an option to run the file after install and I use the new name variable to file.run so this is all working correctly but the problem is that I also need to update the following with the new name, how do I do that?

shortcuts on system
uninstall data
i think there might be more..

Brett
11-16-2007, 09:42 AM
Before we get into that, let me ask you this - do you know the value of PrepINum() before you build the install? If so, use a build constant at design time rather than a script at runtime.

If you can only get that value at runtime, then you will have to use the actions to create the shortcut instead of the checkbox on the properties dialog. The uninstall can be modified using the UninstallData actions.

mike54721
11-16-2007, 10:13 AM
The function is in the global functions and can change everytime. It returns a numeric value (eg. 1201). The value is determined before any user action is needed, eg. the value is known at startup but not before.

I looked at uninstall data functions and there doesn't seem to be an update, but I will just do a remove then add again with the new name.

How do I create shortcuts though?

Brett
11-16-2007, 10:28 AM
You create a shortcut with the Shell.CreateShortcut action. You can add the shortcut to the uninstall using the UninstallData.AddItem action.

There are a couple of ways to have the dynamically named file removed during uninstall:

1. Use UninstallData.AddItem to add an entry for the new filename. DO not worry about removing the old one - it will have no effect.

2. Write the name of the file to the Registry or an ini file and then in your uninstall script, read it back in and use a File.Delete action to remove it.