Archive: A question regarding File command


A question regarding File command
I tried to use File command as,
File /nofatal $1

NSIS couldn't find $1 but if I print out $1, I check the file does exist. If I use File as,
File /nofatal "C:\temp\test.txt" (assume $1="C:\temp\test.txt"),
then it works. What is wrong with File /nofatal $1? Thanks.


The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.


Originally posted by demiller9
The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.
I see. Thanks so much for your explanations!

Originally posted by demiller9
The FILE command is used during the compile time to compress the files into the setup program. $1 does not have a value during compile time, so the file you want to point to later cannot be put into the setup program.

During execution, FILE $1 would try to extract the file named by "$1" to the current working directory; unfortunately it will fail because the compile time function won't have worked.
I have one more question. Since File command is used during the compile time. I wonder if there is any similar command which could be used during the run time? Thanks.

Use the /oname= (out name) switch.

Stu


Originally posted by Afrow UK
Use the /oname= (out name) switch.

Stu
Could you explain what could be done by using /oname that could NOT be done by using /nofatal? Basically, my trouble is that the file after the command File doesn't exist in compile time. So File command always complains file not found. I wonder if there is any way to execute File command or similar command in run time since the output file can only be determined in run time. Thanks.

Originally posted by dullboy
Could you explain what could be done by using /oname that could NOT be done by using /nofatal? Basically, my trouble is that the file after the command File doesn't exist in compile time. So File command always complains file not found. I wonder if there is any way to execute File command or similar command in run time since the output file can only be determined in run time. Thanks.
You're mistaken: You cannot make an installer that only contains file XYZ if some condition is met. If you need it installed at ANY point, the installer MUST have it compressed inside.

What you probably want is this:
${If} (some condition here)
File Yourfile.ext
${EndIf}

The above will always compile Yourfile into the installer, but it will only be extracted (at runtime) if the condition is met.


Or if your problem is that you want to include files dynamically (to make different installers depending on what files you have on your compiling PC), you'll probably have to use this:
File YourDynamicFolder\*.*

Originally posted by MSG
You're mistaken: You cannot make an installer that only contains file XYZ if some condition is met. If you need it installed at ANY point, the installer MUST have it compressed inside.

What you probably want is this:
${If} (some condition here)
File Yourfile.ext
${EndIf}

The above will always compile Yourfile into the installer, but it will only be extracted (at runtime) if the condition is met.


Or if your problem is that you want to include files dynamically (to make different installers depending on what files you have on your compiling PC), you'll probably have to use this:
File YourDynamicFolder\*.*
No, my question is that the files to be extracted do not exist before installation and they will be generated during installation. Is there any way I can do that? Thanks.

You need to think to yourself how you would go about generating these files? What will the files contain? To write to a file at run time, use FileOpen, FileWrite and FileClose.

Stu


I resolved the problems. Thanks for you guys' suggestions. Is there any way to give you guys credits? :-)