cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
doozerIA
Level 3

Problem using Modify Text File to create a new file

Hi, I'm trying to create a new 'links' directory on the Windows filesystem and create a new text file within it which contains just one line.

I am attempting this in the Post-Install section of IA2010, by using Execute Command (to run mkdir to create the new 'links' directory) and then Modify Text File with the New file radio button selected (to create a new file called 'myfile.link' within the new 'links' directory, containing the one line of text I want).

However, when I run the installer there is a problem with creating the new file because it says it cannot find the new directory - even though it was created OK (and I have confirmed it was created on the filesystem).

Here is the relevant snippet from the install.log file (note that C:\Temp already exists on the filesystem before running the installer):

Execute Command: cmd.exe /c mkdir "C:\Temp\links"
Status: SUCCESSFUL

Modify Text File - Single File: New File C:\Temp\links\myfile.link
Status: ERROR
Additional Notes: ERROR - java.io.FileNotFoundException: parent did not exist when attempting touch on path: C:\Temp\links\myfile.link


Is this a timing issue?
I have tried seperating the two commands into different Action Groups - but get the same problem as above.

However, I have tried creating the C:\Temp\links directory myself before running the installer - and then the new file 'myfile.links' is then created successfully.

The above problem only occurs if I let the installer create the new 'links' directory before attempting to create the new file.
It is like the Execute Command does not complete before the Modify Text File is attempted. Wierd!

Does anyone know what I'm doing wrong, or how else I can create a new text file within a new directory, as part of the post-install?

Thanks.
Labels (1)
0 Kudos
(4) Replies
pv7721
Level 20

Why can't you do this in the Install section, maybe as a last action, it might be easier to create the links folder (you've got a built-in action for that in the Install task).
0 Kudos
doozerIA
Level 3

pv7721 wrote:
Why can't you do this in the Install section, maybe as a last action, it might be easier to create the links folder (you've got a built-in action for that in the Install task).


Hi Vlad,

thanks for the reply. I deemed it more of a Post-install activity so decided to put it in there.

I have however previously tried creating the new 'links' directory in the Install section as you suggest, using the Create Folder action. The problem with that is that no matter what destination path I choose in the drop down box (e.g. Temp directory), the directory path field to the right of it always shows '\' and is greyed out so I cannot enter the necessary 'C:\Temp\links' that I would like to. Do you know of any way around this so that I can enter a path of my choosing? If so I could do the create directory in the Install section as you suggest.

Thanks,
Brian.
0 Kudos
pv7721
Level 20

And this path of yours is somewhere completely out of the user installation folder?
0 Kudos
doozerIA
Level 3

pv7721 wrote:
And this path of yours is somewhere completely out of the user installation folder?


Yes it is completely out of the user install folder. Is that not possible then? I hoped I would be able to create a folder anywhere on the filesystem using the Create Folder action.

However I have managed to find a solution - your comment triggered me into thinking that I needed to use a user variable to access outside of the user install folder.

In the Install section I set variable $USER_MAGIC_FOLDER_1$ to the pathname I want on the filesystem (C:\Temp), and then use the Create Folder action, specifying that variable as the destination path and then entering 'links' as the name of the new folder to create.

Then in the Post-install section I use the Modify Text File action to create the new file, and this time the command succeeds because it can find the newly created folder.

I still don't understand why I hit the original problem - where it says the mkdir completed successfully but then can't touch ther parent folder when attempting to create the new file - looks like a bug in InstallAnywhere to me?

Bu anyway the solution is not altogether very intuitive - but it works!

Thanks for the help.
0 Kudos