dullboy
25th January 2011 20:53 UTC
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.
demiller9
25th January 2011 21:09 UTC
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.
dullboy
25th January 2011 21:46 UTC
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!
dullboy
25th January 2011 21:54 UTC
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.
Afrow UK
25th January 2011 22:30 UTC
Use the /oname= (out name) switch.
Stu
dullboy
25th January 2011 23:22 UTC
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.
MSG
26th January 2011 06:44 UTC
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\*.*
dullboy
26th January 2011 16:57 UTC
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.
Afrow UK
26th January 2011 17:47 UTC
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
dullboy
26th January 2011 18:40 UTC
I resolved the problems. Thanks for you guys' suggestions. Is there any way to give you guys credits? :-)