Skip to content
⌘ NSIS Forum Archive

Trouble with specifying file

5 posts

nervous pervous#

Trouble with specifying file

Is it possible to use absolute file names with the File command? I'm doing the following in the main section of the script:

StrCpy $R0 "$TEMP\Sample"
CreateDirectory "$R0"
SetOutPath "$R0"

File "/oname=\bin\DLLs\mydll.dll" "C:\dev\SomeDirectory\bin\DLLs\mydll.dll"
It compiles fine and I'm pretty sure the files are being found because the exe size is large. However, when I run the setup the files are not extracted. The documentation on this command is very brief, so am I missing some crucial point?

Thanks
JasonFriday13#
This line:

"/oname=\bin\DLLs\mydll.dll"
is not specifying an absolute path, so the file is being extracted, but you don't know where. Specifying an absolute path like:

File "/oname=$R0\bin\DLLs\mydll.dll" "mine.dll"
or
File "/oname=$INSTDIR\bin\DLLs\mydll.dll" "mine.dll"

should extract the file to where you want it.

[edit] Forgot to add the end onto the post.[/edit]
nervous pervous#
Sorry for the confusion, I meant specifying an absolute path as the source file.

I didn't think I have to specify an absolute path for the destination file. The documentation said that it will create the file as $OUTDIR\$X where /oname=$X. And I am setting the output path correctly.

I tried removing the /oname option and my files are extracted to the Sample directory. So it seems like I am misusing this option. One guess is that the /oname option does not create the directory structure for you, and that I have to create it manually. Can somebody verify if this is true?

I will try your suggestion and simply specify the absolute path for the /oname option as well.

Thanks for the help!
Comperio#
I had to test some of the things to determing the real behavior. Here is how it works:
  • First, /oname means output name. It allows you to specify the output path/file name for a single file rather than having to specify SetOutPath for each file.
  • When using /oname=, The part after the equal sign is the output path/file name. In your first example, you were specifying the output as the relative path. (probably where the confusion started.)
  • /oname option DOES NOT create the directory structure. You'll have to make a call to CreateDirectory first.
  • It's always better to specify an absolute path when extracting, but relatives paths will work find for the source file names.
  • You can use SetOutPath followed by a regular file command to accomplish the same thing the /oname switch. For example, this:
    File "/oname=C:\temp\foo.exe"
    is exactly the same as this:
    SetOutPath "C:\temp"
    File "foo.exe"

Personally, I prefer the long way as it gives more control and allows more files to be added to a single directory. Plus, adding more files to the list later is much easier. But either way will work.

Hope this helps clear up the confusion.
nervous pervous#
Thanks! This is exactly the information I needed. I couldn't find this in the docs. Is it available somewhere else? IMHO, this information should be in the documentation, at least the bit about the /oname option not creating the directory structure.