![]() |
#1 |
Junior Member
Join Date: Nov 2015
Posts: 23
|
Regular expressions for path?
Been looking through google to try to find something similar. Shows me the NSISpcre plugin. Not particularly against it or anything, but I'm new to NSIS already and if I don't need it I'd prefer not to use it.
I'm basically looking to build an installer for a plugin that would install files into a particular location. The path however, from different versions would vary from computer to computer. ex. C:\Program Files\[A random program]\[Program Name 2012]\ C:\Program Files\[A random program]\[Program Name 2015]\ How would I go about expressing different version numbers? Same goes for Program Files as there is 32bit version of windows and 64 bit version of windows. Any help would be greatly appreciated. |
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
Assuming that the application is installed under a certain fixed path is a bad idea! You could try to search for the application (recursively), using the FindFirst and FindNext functions, but that's still slow and error prone. Instead, most applications will write their location to the registry - under a well-known registry key/value. So, in order to "detect" the install location, you just read the appropriate registry value.
My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Nov 2015
Posts: 23
|
Okay so I've done what you've said with success. I'm able to find the path based off of the registry. My problem now is that a certain file is also year dependent. as in [ApplicationName][year].[fileextension].
I was able to use IfFileExists to find out if say [ApplicationName]20*.lsp (it's an lsp file I'm looking for) to find if a certain path contains that file in the year 2000 to 2099. It's able to do that. My question is now, how do I put this into a variable to use? Putting the asterisk in a strcpy statement, detailprint or a fileopen puts the literal character in there. I need to be able to open any year version basically whether it be a file in the year 2000 or the year 2099 |
![]() |
![]() |
![]() |
#4 |
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
If possible somehow, try to detect the exact file name from the registry. Or based on some other available info.
If it's really not possible and you have to search for the file at runtime, use something like: PHP Code:
My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
![]() |
![]() |
![]() |
#5 | |
Junior Member
Join Date: Nov 2015
Posts: 23
|
Quote:
It's possible but I'm unsure if the registry would be the same across all versions of the program. So I'm trying to open it as soon as I find the file. I know how to read/write with NSIS, but the above code you posted I don't 100% understand. Is this piece of code solely to detect whether or not the file exists in the directory? I want to be able to find the file, hold it in a variable (I've done up to this part), and then check the variable to see if it fits the regex pattern I stated in the thread and then open if it does match. I just tried PHP Code:
|
|
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Nov 2015
Posts: 23
|
Never mind, I didn't need to do what I just posted. I'm just running loops in my head. Thanks a lot for your help.
|
![]() |
![]() |
![]() |
#7 |
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
|
The code above iterates over all files that match the specified template. In the example I used "$INSTDIR\*.foo", so it would iterate over all .foo files in the install directory. But you can use whatever template you deem suitable for your needs...
For details see the NSIS manual: http://nsis.sourceforge.net/Docs/Cha...html#FindFirst My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|