- NSIS Discussion
- New to NSIS, simple problem, hard for me
Archive: New to NSIS, simple problem, hard for me
Shoshanna
15th January 2004 02:40 UTC
New to NSIS, simple problem, hard for me
Hello :)
I have read a lot of threads and looked at different tutorials and faq's and I think I may have overly saturated my brain with this :eek:... I am one of the people behind a NWN (Neverwinter Nights) PW (Persistant World) located here. For our PW to work, people need to download files called HAK's, HAK's are sorta like plugins for NSIS, in that they contain custom content, like textures, models, engine mods, etc... to extend the games functionality.
Anyway, a lot of users seem to have difficulty installing the haks in the right directory, by default it is located here
C:\NeverwinterNights\NWN\hak
of course people may install into other directories and or drives, but the structure remains the same obviously. So I figured I'd try NSIS, since its free and very powerful, and in the future I could use it more as a utility to download HAK's, and check periodically for updates, but thats in the future LOL!
To get to the point, I'd like it to be able to read the NWN install from the registry and install to the hack directory, I made a simple installer that is set to the default location and you can browse to the right directory if its not a default install, but that makes it little more than the SFX setup we have now, I looked at examples and they seem more complex than what I need, or I am just not doing it right, the latter is probably true do to my lack of scripting prowess :(
I did not mean to write a page worth of words, But I rather be thorough, I am also enclosing registry information and my -very- basic script...
Thanks so much for your time,
Shoshanna
dajvid
15th January 2004 07:27 UTC
Hi Shoshanna,
Here's my take on you're wanting to do in your script (please reply if any of my assumptions are incorrect):[list=1][*]Your installer requires Neverwinter Nights to be installed. Making this assumption allows us to guarantee the registry key for the installation folder will exist if it is installed.[*]HAK's are always installed to the "hak" folder under the installation folder for Neverwinter Nights.[/list=1]
If these assumptions are correct, you can use NSIS to:[list=1][*]Check that Neverwinter Nights is installed (abort if it isn't), and[*]Automatically determine the folder to install the HAK's to without any user intervention (simplifying the installation experience for users).[/list=1]
Here's what I'd do:[list=1] [*]Make these changes to the ".onInit" function to check whether Neverwinter Nights is installed:
Function .onInit
ReadRegStr $INSTDIR HKLM "SOFTWARE\BioWare\NWN\Neverwinter" "Location"
IfErrors 0 ShowSplashScreen
MessageBox MB_OK "Setup cancelled. Neverwinter Nights is not installed."
Abort
ShowSplashScreen:
<<insert your code to display a splash screen here>>
FunctionEnd
[*]Remove the lines setting "InstallDir" and "DirText" because the installation folder is now already set in the ".onInit" function.[*]Insert the following line to hide the directory selection page:
DirShow hide
[*]and finally, change the "SetOutPath" location to installation folder:
SetOutPath $INSTDIR\hak
[/list=1]
I've only cobbled this together quickly, so apologies for any mistakes, however hopefully this should be on the lines to what you're after.
Ta,
Dave.
Comm@nder21
15th January 2004 13:19 UTC
DirShow hide doenst work yet, i think.
why do u want to include the directory-page into ur installer? simply delete the "Page directory" line from ur script.
if u need advanced help in installing mods, i've already written a nice working script for bf1942 mods.
but i think, it's basicly the same on both games.
Joost Verburg
15th January 2004 13:23 UTC
DirShow does not exist anymore in NSIS 2.
Some NSIS 1 users used it incorrectly, 'DirShow hide' shows the directory page if the folder is invalid, you don't have to add it to hide the directory page.
In NSIS 2, everything works with the new page commands and functions.
dajvid
16th January 2004 01:52 UTC
My mistake with the "DirShow Hide", remove the Directory page as indicated by Comm@nder21 and Joost.
Ta,
Dave.
Shoshanna
16th January 2004 04:35 UTC
Closer...
I am such a dork , I was wanting to use the Modern UI but I was using the classic instead and did not realise it...that should be an indicator of how lame I am with NSIS... PHP seems easier, even though I am not the best at that, though it doesnt kick my butt like NSIS does :P
Anyway, I have tried both the Modern and Classic GUI's and I like classic better for this, even though modern seemd to find the right "path" with my script and classic gets stuck at C:\NeverwinterNights\NWN\ even though I am reading from the registry like this...
Function .onInit
ReadRegStr $INSTDIR HKLM "SOFTWARE\BioWare\NWN\Neverwinter" "Location"
and set this for my "SetOutPath"
SetOutPath "$INSTDIR\hak"
Again I will atach my slightly less lame script ;)
Thanks again,
Shoshanna :)
Joost Verburg
16th January 2004 16:07 UTC
The is absolutely no difference in script code between the Classic UI and Modern UI. The only difference is the interface.
You have probably used a different script. To detect the installation folder use InstallDirRegKey.
Joel
16th January 2004 21:06 UTC
Maybe some suggestions! :)
1. Why not use both directory instructions:
InstallDir $PROGRAMFILES\SomePath
InstallDirRegKey HKLM "SOFTWARE\BioWare\NWN\Neverwinter" "Location"
2. Before your
SetOutPath "$INSTDIR\hak"
CreateDirectory "$INSTDIR\hak"
SetOutPath "$INSTDIR\hak"
;...
BTW: Welcome to the forums :D
Vytautas
17th January 2004 14:00 UTC
Lobo Lunar there is no need for the CreateDirectory command as SetOutPath automatically creates the Path if it does not exist.
Vytautas
dajvid
20th January 2004 06:27 UTC
Hi Shoshanna,
Here's my suggestion for your sample script. It works fine on my computer. I'd recommend keeping the check for registry key so that the installer can abort gracefully if it cannot be detected. This script automatically finds where Neverwinter Nights is located and installs the files without prompting the user. I'd recommend adding a Welcome page so that the user knows what's being installed in case they accidentally double click on the setup file.
Ta,
Dave.
Comm@nder21
20th January 2004 21:00 UTC
hmm, maybe i'll posting a version of my bf1942-script here in the next days.
what, if the user didn't install the game, but only copied the gamefiles? (not in illegal ways, i mean) then u can't read out the reg-path and the user can't install.
Shoshanna
21st January 2004 03:20 UTC
This thread has grown in my absence...:) Thanks for all the replies and the welcome Lobo, and the script as well Dave:) (have not had a chance to test it out as I was away visiting family, I will soon though ;))... Commander21 is right, while we will be running the dedicated server on our end, that does not mean that some testers and scripters for our world won't be running a server too, to use with the haks from our PW, the server does not install, it just unpacks and does nothing to the registry, so the option to manually search for the directory would be nice :) would there be a way to make it so that if it does not find the keys in the registry, it would prompt the user to find the directory manually? That could possibly be the best solution :)
Vytautas
21st January 2004 03:24 UTC
Yes that is quite possible. After reading the registry value, you should check if it contains the required path and if it does skip the directory selection page, using the abort command in the pre function of the directory page.
Vytautas ;)
deguix
21st January 2004 12:10 UTC
Have a function in the Archive for Searching files.
(I should put my program installer script in the Archive, because have some REALLY useful codes for installation security in your case...)