Skip to content
⌘ NSIS Forum Archive

Script to only install if folder exists

2 posts

shortyg83#

Script to only install if folder exists

I am making a file to install patches on 5 computers. Two of the computers have software that the other three don't and I need it to stay that way.
How can I script so that it only runs a certain executable in the service pack if a certain folder or file already exists on the pc. And if that folder or file does not exist it skips that exe from the service pack.
Anders#
!include LogicLib.nsh
Section
${If} ${FileExists} "$ProgramFiles32\Company\MyApp\App.exe"
    InitPluginsDir
    File "/oname=$PluginsDir\MyAppPatch.exe" "c:\mysourcefiles\MyAppPatch.exe"
    ExecWait '"$PluginsDir\MyAppPatch.exe"' ; Maybe supply the "$ProgramFiles32\Company\MyApp" path as a parameter?
    Delete "$PluginsDir\MyAppPatch.exe"
${EndIf}
SectionEnd