Skip to content
⌘ NSIS Forum Archive

File "/oname" $variable

2 posts

manstir#

File "/oname" $variable

Problem:
File "/oname=$WINDIR\system32\$UpdateFileSys32" "$UpdateFileSys32Dir\$UpdateFileSys32"

Error: File "$UpdateFileSys32Dir\$UpdateFileSys32" -> no files found.

The File Function does not except a variable instead a SrcPath. Do you know a workaround?

Description:
My Installer copies some .dll files into the $WINDIR\system32 folder.
All these Files are stored in the directory \src\system32.
before the installert copies the file to the destination it checks the version of the existing files. The Installer checks File after File in this Procedure. By the Time I would like to write the File I got the Name in a Variable!

Code:
StrCpy $UpdateFileSys32Dir "src\system32"
  
  FindFirst $0 $UpdateFileSys32 "$UpdateFileSys32Dir\*" ;$INSTDIR\*.txt
  loop:
    StrCmp $UpdateFileSys32 "" done
         ${If} $UpdateFileSys32 != ""
      ${GetFileVersion} "$UpdateFileSys32" $FileVersionO
        DetailPrint "Datei $UpdateFileSys32 Version: $FileVersionO liegt zur Installation bereit"
        ${If} ${FileExists} "$WINDIR\system32\$UpdateFileSys32"
          ${GetFileVersion} "$UpdateFileSys32" $FileVersionN
          DetailPrint "File already exists: $WINDIR\system32\$UpdateFileSys32 Version: $FileVersionN"
          ${VersionCompare} $FileVersion0 $FileVersionN $tmp
          ${If} $tmp == "1"
            DetailPrint "The existing File is newer. $UpdateFileSys32 File not replaced"
          ${Else}
            DetailPrint "The existing Version is equal or older. $UpdateFileSys32 Copy File... "
            ;SetOutPath "$WINDIR\system32\"
            File "/oname=$WINDIR\system32\$UpdateFileSys32" "$UpdateFileSys32Dir\$UpdateFileSys32"
            DetailPrint "$UpdateFileSys32Dir\$UpdateFileSys32 File replaced"
          ${EndIf}
        ${EndIf}
        DetailPrint "---"
    ${EndIf}
  FindNext $0 $UpdateFileSys32
  Goto loop
done: 
Afrow UK#
You've got your variable use messed up.
Variables are for run time use, so naturally you can't use them on compile time.

-Stu