- NSIS Discussion
- How do I create a simple installer to copy files to multiple directories?
Archive: How do I create a simple installer to copy files to multiple directories?
Panarchy
7th April 2009 08:36 UTC
How do I create a simple installer to copy files to multiple directories?
Hello
I would like to know how to create a simple installer using NSIS which will, at launch of setup, ask me to choose (from a Drop down list or radio buttons) which Operating System I am installing it on (or could auto-detect this?).
Firstly, I'll explain what I need done.
I need 2 files (.exe and .ini) copied to the following directories;
On Windows (XP, Server 2003 and everything before);[list=1][*]%WINDIR%\servicepackfiles\i386[*]%WINDIR%\system32\dllcache[*]%WINDIR%\system32[*]%WINDIR%[/list=1]On New Windows! (Vista, Win7, Server 2008 etc. including x64);[list=1][*]%WINDIR%[*]%WINDIR% \servicepackfiles\i386[*]%WINDIR% \system32\dllcache[*]%WINDIR%\SysWOW64 - (NOTE: Probably only on Vista x64)[*]%WINDIR%\winsxs\amd64_microsoft-windows-notepad_31bf3856ad364e35_6.0.6001.18000_none_cb3928ff285d2ca9 - (NOTE: Probably only on Vista x64)[*]%WINDIR%\winsxs\amd64_microsoft-windows-notepadwin_31bf3856ad364e35_6.0.6001.18000_none_9ee86862b36a7eff - (NOTE: Probably only on Vista x64)[*]%WINDIR%\winsxs\x86_microsoft-windows-notepad_31bf3856ad364e35_6.0.6001.18000_none_6f1a8d7b6fffbb73[/list=1]Any advice on how I could do this would be truly appreciated.
Thanks in advance,
Panarchy
sgiusto
7th April 2009 10:12 UTC
Hello,
the SetOutPath command is used to specify the destination folder of files and the constants $WINDIR and $SYSDIR contain the windows and system folder of the system you are installing on.
Search nsis site for GetWindowsVersion macro that detects the windows version you are running on.
Last but not least RTFM!
These are baisc features and are well documented.
Regards
Stefano
Panarchy
7th April 2009 13:07 UTC
Thanks, I'll research what you have described!
Documentation wasn't simple...
Panarchy
7th April 2009 13:35 UTC
Okay, well here is what I've worked out so far.
Please tell me what I am doing wrong;
Name "Notepad2"
OutFile "Notepad2 Setup.exe"
LicenseText "You must agree to this license before installing."
LicenseData "license.txt"
InstallDir "$WINDIR"
InstallDir "$WINDIR\servicepackfiles\i386"
InstallDir "$WINDIR\system32\dllcache"
InstallDir "$WINDIR\system32"
DirShow hide ; (make this show to let the user change it)
DirText "Select the directory to install myApp in:"
Section "" ; (default section)
SetOutPath "$INSTDIR"
File /-y notepad.exe
File /-y notepad.ini
SectionEnd ; end of default section
; eof
Thanks in advance,
Panarchy
Afrow UK
7th April 2009 14:54 UTC
You only use InstallDir once to set the default installation directory for the Directory page. You aren't even using a Directory page so you shouldn't be using it. Just use SetOutPath on the 4 directories with the 2 File instructions after each. Also, what is /-y? There is no such switch for the File instruction.
This is a much better install.
!include MUI2.nsh
Name `Notepad2`
OutFile `Notepad2 Setup.exe`
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
Section
!macro ExtractNotepad2 ToDir
SetOutPath `${ToDir}`
File notepad.exe
File notepad.ini
!macroend
!insertmacro ExtractNotepad2 $WINDIR
!insertmacro ExtractNotepad2 $WINDIR\servicepackfiles\i386
!insertmacro ExtractNotepad2 $SYSDIR\dllcache
!insertmacro ExtractNotepad2 $SYSDIR
SectionEnd
Stu
Panarchy
7th April 2009 15:24 UTC
Sweet!
Nice, smaller, a little harder to understand, but all in all much better then my 1st attempt.
Almost perfect!
Thanks for your help, now I just need to work out how to make it install differently when installed on Vista, Server 2008 & Windows 7.
If you know how I can do so, without creating a separate installer, please tell me!
[The] GetWindowsVersion macro detects the windows version you are running
Perhaps this can be used?
Thanks in advance for any extra advice,
Panarchy
PS: Once again, thank you for what you have posted!
Afrow UK
7th April 2009 17:12 UTC
You should just need to add RequestExecutionLevel user or RequestExecutionLevel admin in there.
Read it up in the manual.
Stu
Panarchy
8th April 2009 03:33 UTC
Thanks, I'll do that.
In the meantime, I'm getting some errors with the unedited script you wrote;
Error in macro MUI_PAGEDECLARATION_LICENSE on macroline 17
Error in macro MUI_PAGE_LICENSE on macroline 6
Error in script "C:\Users\Panarchy\Documents\Almost Perfect.nsi" on line 7 -- aborting creation process
Please tell me how to fix them.
Thanks in advance,
Panarchy
PS: Where should I put notepad.exe and notepad.ini?
Panarchy
11th April 2009 15:42 UTC
*bump*
Comperio
11th April 2009 16:27 UTC
For your last two questions:
I assume that your MUI error is that the file 'license.txt' does not exist in your MUI folder.
Also, the files notepad.exe and notepad.ini should be in the same folder as your script (unless you specific the full path to the file.) This is explained in the main NSIS help for the FILE command. (a copy of it is found here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.5)
And for usage about WinVer, have a look inside the main header file--WinVer.nsh--found in the includes folder of you NSIS install.
For other help, you should consider spending some time browsing your NSIS installation folder (especially look a the DOCS and EXAMPLES folders--there's some good documentation and examples for MUI that will explain each command in detail.) You might also want to take some time reading through the FAQs on the wiki.
Panarchy
12th April 2009 00:38 UTC
Thanks, will do.
Panarchy
13th April 2009 06:11 UTC
Hello
Okay, everything now works pretty much perfectly, however I would like to customise a few things.
Any idea how I can change the following text?
http://i39.tinypic.com/35hrear.jpg
Would really appreciate any suggestions.
Thanks in advance,
Panarchy
Panarchy
17th April 2009 14:50 UTC
*bump*
Afrow UK
17th April 2009 17:48 UTC
There is much you can learn by reading the docs.
!define MUI_LICENSEPAGE_TEXT_BOTTOM `my text`
BrandingText `my text`
Stu
Panarchy
18th April 2009 05:15 UTC
Thanks for your reply.
The BrandingText one works, however this one;
!define MUI_LICENSEPAGE_TEXT_BOTTOM `my text
Doesn't.
Please tell me how to get the 2nd one to work.
Thanks in advance,
Panarchy
PS: Thanks for the BrandingText one, really appreciate it.`
Afrow UK
18th April 2009 13:30 UTC
Have you put the define before inserting the page macros?
Stu
Panarchy
18th April 2009 15:29 UTC
Thanks, that did the job.
Would it also be possible to change the following text?;
http://i40.tinypic.com/2j4c7zm.jpg
And also to make the font size bigger (much bigger). Alternatively if you can tell me how to create another page in the wizard, one which I can use as a CAUTION page telling the user that it will replace Notepad with Notepad2.
Thanks in advance for any extra help,
Panarchy
PS: Thanks once again for all you've helped me with!