NSIS - Define InstallDir depending on FileExists
Asked Answered
E

1

9

What I want to do with this script is to copy a file in a folder who already exists. But it can be at the root (C:) or in the program files.

There what I want, but this script doesn’t work:

  ${If} ${FileExists} "C:\Cisco Systems\VPN Client\Profiles"
    InstallDir "C:\Cisco Systems\VPN Client\Profiles"
  ${ElseIf} ${FileExists} "$PROGRAMFileS\Cisco Systems\VPN Client\Profiles"
    InstallDir "$PROGRAMFileS\Cisco Systems\VPN Client\Profiles"
  ${EndIf}

Someone can help me?

Thank you

Elect answered 20/10, 2009 at 15:17 Comment(0)
P
11

Set $instdir in .onInit with StrCpy:

!include LogicLib.nsh

InstallDir "C:\Something\something" ; Used if neither of the files exist.

Function .onInit
${If} ${FileExists} "C:\Cisco Systems\VPN Client\Profiles"
  StrCpy $InstDir "C:\Cisco Systems\VPN Client\Profiles"
${ElseIf} ${FileExists} "$ProgramFiles\Cisco Systems\VPN Client\Profiles"
  StrCpy $InstDir "$ProgramFiles\Cisco Systems\VPN Client\Profiles"
${EndIf}
FunctionEnd
Pigtail answered 20/10, 2009 at 20:10 Comment(1)
That is, something like: strCpy $INSTDIR "C:\Your\Path" in a Function .onInit block.Hera

© 2022 - 2024 — McMap. All rights reserved.