|
|
#1 |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
Finding an executable. ${Locate}
Good afternoon,
The task I'm trying to accomplish cannot be as difficult as it seems. It's just an installer that looks for a file name, anywhere on the System, and makes thats the default install path. I looked at the InstallDirRegKey function and it doesn't work for me, as there is no key. Trying to get the ${Locate} thing work for me is failing me every way i can think of. I am not a professional programmer, but I do hobby stuff. Unfourtantley I can't find a single good example of the Locate function/macro being used that is complete code, just often Peusydo Code. Can somebody please, just show me an example or link me to an example where a there is a script that searches for a file, then changes the $INSTDIR to match that? I also want to append a directory to the returned path. For example, it should return (example: C:\programname\file.exe) i want to add \Data\Reports to that, so the default install string would be C:\programname\Data\Reports. Does anybody have any examples of that, that work. Thanks. |
|
|
|
|
|
#2 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
"Anywhere on the System" could be a long delay on script execution.
1st use ${GetDrives} (see the examples in nsis documentation) and then ${Locate} the file on the discovered drives, (also pretty plain examples in documentation). You should add all the above in function .onInit if you want to change the $INSTDIR. Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
Quote:
${Locate} "C:\" "/L=FD /M=Program.exe " "FoundRB" IfErrors 0 +2 MessageBox MB_OK "Error" IDOK +2 MessageBox MB_OK "$$R0=$R0" Function FoundRB StrCpy $R0 $R8 ****StrCpy $R0 $R0 "\Data\Reports\" StrCpy $0 StopLocate Push $0 FunctionEnd I can get it to find the file, but i want to take that 'found path' and add \data\reports onto it, but StrCpy instructions don't show how to append or merge or add, or combine or whatever you want to call sticking 2 strings together. I have tried every variation I could think of (as shown above with (****)) Nothing works. So that way, when the $R0 variable gets returned, it will be c:\programlocation\Data\Reports as the install path. Also, i tried even getting the .onInit to work and it gives nothing but errors about trying to use ${Locate} in it. |
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
Append text to a register:
StrCpy $R0 "$R0\Data\Reports\" |
|
|
|
|
|
#5 | |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
Quote:
Yes, thank you that worked. I had just figured that out before checking back here
|
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
I have got this working now, however it only searches C:\
Function .onInit ${Locate} "C:\" "/L=FD /M=program.exe " "FoundRB" StrCpy $INSTDIR $R0 FunctionEnd Function FoundRB StrCpy $R0 $R8 StrCpy $R0 "$R0\Data\Reports\" StrCpy $0 StopLocate Push $0 FunctionEnd The one thing I notice is, however, it appears to be 'frozen' at the start (as it is searching the HDD). Is there a way to pop up a quick box , or text line , stating 'Searching for Installed Product'.. or something of that type. |
|
|
|
|
|
#7 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
${Locate} "C:\" is not good enough, you'd need a combination with the function ${GetDrives} if you want to search on every HDD available.
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#8 | |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
Example?
Quote:
Thanks, |
|
|
|
|
|
|
#9 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
It's not too hard. GetDrives has a callback function (basically a function that it calls lol) and in that function you can call Locate, like shown in this thread:
http://forums.winamp.com/showthread.php?threadid=264471 Stu |
|
|
|
|
|
#10 | |
|
Junior Member
Join Date: Jun 2007
Posts: 6
|
Quote:
![]() Thanks again for all your help. |
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|