eliteeservices
4th January 2009 22:04 UTC
Get File path and use as variable
How is this possible:
find an installation of a program by searching for the filename (program could be installed in any folder:
$programfiles\abc1
$programfiles\abc2
Wherever it is installed, the file will exist. Then, set the path to where it is found, i.e. if it's in abc1 then copy entire directory structure from abc3 to abc1.
Is this possible / how is it?
Joel
4th January 2009 22:13 UTC
Try one of this:
http://nsis.sourceforge.net/Search_f..._or_Directory_(Alternative)
http://nsis.sourceforge.net/Search_For_a_File
http://nsis.sourceforge.net/Locate_plugin
Just don't expect Windows keep track of every file you copy or install, without registering its path.
Afrow UK
4th January 2009 23:52 UTC
You don't need to use any recursion for this. Just a simple loop will do:
StrCpy $INSTDIR ``
ClearErrors
FindFirst $R0 $R1 $PROGRAMFILES\*.*
${DoUnless} ${Errors}
${If} $R1 != .
${AndIf} $R1 != ..
${AndIf} ${FileExists} $PROGRAMFILES\$R1\*.* # is it a folder?
${AndIf} ${FileExists} $PROGRAMFILES\$R1\some_file.exe
StrCpy $INSTDIR $PROGRAMFILES\$R1
${Break} # found install dir; break out of loop
${EndIf}
ClearErrors
FindNext $R0 $R1
${Loop}
FindClose $R0
${If} $INSTDIR == ``
MessageBox MB_OK|MB_ICONINFORMATION `App not found blah!`
Abort
${EndIf}
Stu