How to rename file in Install4j? - install4j

How can I rename file in install4j?
I have a step to choose the file by user, and if user uploads the file with different name then x.txt i need to rename it back with some post action back to x.txt
I see that install4j has option to Move files and directories, but I see only the destination as a folder, not a file name.
I see only one way how to do it by creating "Run script" post action and write code in Java to actually rename the file.
Is any other standard options in Install4j to do it?

If the "Source files or directories" property of the "Move files and directories" action is set to a single file, the "Destination directory" property can be a file name as well and then the action will rename the file.

Related

Is there anyway to have different destination name of the installing file at than the source name?

I want to have different file name at the destination side after installing it. Is there anyway to do it? I did not get that option in the Add Files and Directories action under Define Distribution tree. Please advise.
The "Install files" action has a "Directory resolver" script to change the installation directory for each file, but there's no facility to change the file name.
You would have to use a "Move files and directories" action for that purpose.

Install4j setting the file association of my exe to a file extension

Ive written a pdf viewer and used install4J to create an exe launcher. I'd like to prompt to change the file association for .pdf to be my exe.
Add a "File associations" screen to your installer and then a "Create a file association" action to the "Installation" screen. The "File associations" screen will pick up the action and ask the user if the action should be performed.

Can install4j update the xml files in the .war or .jar during 'Installer->Installation'?

This question is in regards to install4j 4.2.8.
We can get the users' information from their input.
It's easy to update the xml files with users' input.
But is it possile to replace the xml files in the war/jar file with above modified xml files during installation?
Is there any action can do this job?
You would have to extract the WAR file to a temporary directory with a "Extract ZIP file" action, run the "Replace text in XML files" action on the XML file and use a "Create a ZIP" file action to overwrite the original WAR file.
Update for install4j 6.1+
Since install4j 6.1, there is a "Modify ZIP file" action that can modify files inside a ZIP file.

Viewing a modified file in eclipse

I was adding a simple file to one of my programs that updates when I run the program with a particular parameter.
The file updated fine, but it is stored in the /bin directory and I can't figure out how to view the file within the editor.
I can see that the file is updated when I traverse the bin folder manually and open it with notepad.
Is there a way to view the file within the editor?
edit: I have a file in the project already but I doesn't update, instead the copy in the bin folder does; Can I connect the two somehow?
Your <project>/bin directory is being filtered from view. Right click on your project, select Show In->Navigator then you should be able to see your /bin directory and double click your file to have it open in an editor.
Alternatively, you can use ctrl-shift-r to open the Open Resource dialog, from the triangle drop down menu check Show Derived Resources, and then type in the name of your file.
The /bin directory is managed by the Eclipse builders and so you may lose your file if you do a clean. I would suggest using a different directory to house your runtime files.

Application Deployment

I deployed an application using this method and it worked very good. However, there are 2 missing things that I been trying to find but can't:
1) How do I include resource files in the installation? I have a folder with files that have some user data, and those need to be there after the installation so the application can run, this is an oversimplified example I'm working on (I need to include NecessaryFile1.xml, NecessaryFile2.xml and NecessaryFile3.xml and the folder they're in):
alt text http://img193.imageshack.us/img193/7782/resources.png
2) How can I put the application in the start -> programs menu? It doesn't seem to do that either. It just puts it in the C:\Program Files\My Company Name\ApplicationName\ directory.
Thanks for any suggestion!
Go to your Setup project in Visual Studio. In the "File System" tab, locate "Application Folder". Right-click and then click Add | Folder. Name the new folder "Data". Right-click on the new "Data" folder and click Add File, then add the needed XML files. Repeat for as many different folders and/or files as required by your application.
When you compile and run your setup project, the "Data" folder and its contents will be deployed along with the application.
Click on each XML file in the Solution Explorer and then in the Properties window below (see your screenshot) you click and change "Build Action" to "Copy" and "Copy to Output Directory" to "Copy If Newer". That does the trick for me, at least with ClickOnce...