- NSIS Discussion
- Code won't compile! - Help please!
Archive: Code won't compile! - Help please!
Panarchy
1st June 2009 06:43 UTC
Code won't compile! - Help please!
Hi
Just trying some code & unfortunately I can't get it to work.
I've tried deleting lines 9, 10, 11, 12 & 38-42. But it still won't compile.
I've tried within one set of Apostrophe's, and within 2;
CreateShortcut "$STARTMENU\maint\maint.lnk" "$ProgramFiles\maint\maint.exe"
Yet I still find myself unable to successfully compile the script.
Could someone please help me get the following (or similar) to compile?
!include MUI2.nsh
Name `Maintenance`
OutFile `Maintenance Setup.exe`
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$DESKTOP\Maintenance MMC.msc"
!define MUI_FINISHPAGE_RUN "$DESKTOP\Maintenance.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Open this"
!define MUI_FINISHPAGE_RUN_TEXT "Open that!"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
Section
!macro ExtractMaintenance ToDir
SetOutPath `${ToDir}`
File "Maintenance Script.exe"
File "Maintenance MMC.msc"
File "Backup Directory.exe"
!macroend
!macro ExtractMaint ToDir
SetOutPath `${ToDir}`
File "Maint.exe"
!macroend
!insertmacro ExtractMaintenance "C:\Install\CD\Applications\Tools"
!insertmacro ExtractMaint "$PROGRAMFILES\maint"
CreateShortcut "$STARTMENU\maint\maint.lnk" "$ProgramFiles\maint\" "maint.exe"
CreateShortcut "$DESKTOP\Maintenance.lnk"
"E:\Forstall\Applications\Tools\" "Maintenance Script.exe"
CreateShortcut "$DESKTOP\Maintenance MMC.lnk"
"E:\Forstall\Applications\Tools\" "Maintenance MMC.msc"
SectionEnd
Thanks in advance,
Panarchy
jpderuiter
1st June 2009 10:25 UTC
What is the error message you get?
It looks like you start the rest of your CreateShortcut parameters on a new line.
If you want to do that, you have to end the first line with a backslash:
CreateShortcut "$STARTMENU\maint\maint.lnk"\
"$ProgramFiles\maint\" "maint.exe"
Panarchy
1st June 2009 22:29 UTC
LOL, I don't believe it!
My script can now compile!
:D
Now just need to work out the following;
- How to make more than one checkbox on the finish page
- & How to successfully create a start-menu shortcut
Please help me work out the aforementioned.
Thanks in advanced,
Panarchy
Panarchy
2nd June 2009 07:14 UTC
Hi
I have two features which I haven't been able to get to work.
1. Can't compile! (LOL)
2. Need multiple Checkboxes on the finish page (one for .exe one for .msc)
Here is my latest code;
!include MUI2.nsh
Name `Maintain`
OutFile `Installer.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 ExtractMaint ToDir
SetOutPath `${ToDir}`
File "Maint Scribe.exe"
File "MMC.msc"
!macroend
!macro ExtractSome ToDir
SetOutPath `${ToDir}
File "Some.exe"
!macroend
!insertmacro ExtractMaint "F:\Install\Applications"
!insertmacro ExtractSome "$PROGRAMFILES\SOME"
CreateShortcut "$STARTMENU\SOME"\
"Some.lnk" "$PROGRAMFILES\SOME\some.exe"
CreateShortcut "$DESKTOP\Maint.lnk"\
"F:\Install\Applications\" "Maint Scribe.exe"
CreateShortcut "$DESKTOP\MMC.lnk"\
"F:\Install\Applications\MMC.msc"
SectionEnd
Please help me with getting this to work!
Thanks in advance,
Panarchy
BTW: When commenting out the following, the code compiles;
!insertmacro ExtractSome "$PROGRAMFILES\SOME"
Afrow UK
2nd June 2009 12:18 UTC
Your CreateShortCut is incorrect. The first parameter must be the full path to the shortcut to be created. The second parameter is the file/path to execute. Check the manual on the correct usage.
To add an additional check box on the finish page requires defining a custom show function (!define MUI_PAGE_CUSTOMFUNCTION_SHOW ...) and in it a ${NSD_CreateCheckBox} line.
Stu
Panarchy
2nd June 2009 22:22 UTC
Thanks for both of your answers.
Could you please also find out why my program doesn't compile?
And help me get the program to compile?
Thanks in advance,
Panarchy
Hint: Line 28
jpderuiter
2nd June 2009 23:37 UTC
The output of the NSIS compiler can be very helpfull.
Please have a look at it.
And if you can't figure out what's wrong, please give us the error reported by the NSIS compiler, so it's easier to see what's wrong.
The NSIS output for your script is:
!insertmacro: ExtractSome
Error: unterminated string parsing line at macro:ExtractSome:1
Error in macro ExtractSome on macroline 1
Error in script "test.nsi" on line 28 -- aborting creation process
When you look closely at this first line of the ExtractSome macro, you might notice that you forgot a single quote after ${ToDir}.
Hence a failed compile.
Panarchy
3rd June 2009 03:59 UTC
Hahahahaha, thanks. Fixed.
Perfect
Panarchy
3rd June 2009 05:15 UTC
Thanks... well everything works now, except the shortcut creation within the start menu.
The file [some.exe] is successfully extracted within %programfiles%, however the shortcut is NOT created within the Start Menu.
Some help here please.
Thanks in advance,
Panarchy
jpderuiter
3rd June 2009 07:15 UTC
Originally posted by Afrow UK
Your CreateShortCut is incorrect. The first parameter must be the full path to the shortcut to be created. The second parameter is the file/path to execute. Check the manual on the correct usage.
Stu
jpderuiter
3rd June 2009 07:19 UTC
You can't split a string on several lines with a backslash I mentioned before.
So it should be:
CreateShortcut "$STARTMENU\SOME\Some.lnk"\
"$PROGRAMFILES\SOME\some.exe"
Panarchy
3rd June 2009 07:27 UTC
Worked it out myself;
CreateShortcut "$SMPROGRAMS\Some.lnk"\
"$PROGRAMFILES\SOME\Some.exe"
Afrow UK
3rd June 2009 17:20 UTC
You can split strings over multiple lines:
MessageBox MB_OK "part 1\
part 2\
part 3"
Your code differs in that you have used quotes thus creating 2 parameters.
Stu
Panarchy
3rd June 2009 23:12 UTC
Okay... I think I understand.
Thanks
Panarchy
4th June 2009 02:05 UTC
How do I make an MMC (*.msc) load at completion of installer?
Currently;
!define MUI_FINISHPAGE_RUN "F:\Install\Applications\MMC.msc"
Which works for *,exe, just not *.msc
Please tell me how I can load the MMC with the checkbox on the Finish page.
Thanks in advance,
Panarchy
Comperio
4th June 2009 05:14 UTC
MSC files themselves are not executable files like EXEs...
:rolleyes:
You'll need to call the actual EXE (MMC.EXE) with parameters. This will probably help get you started: http://technet.microsoft.com/en-us/l.../cc757725.aspx
To run it on the finish page you have two options. You can to supply the EXE name with MUI_FINISHPAGE_RUN and also use MUI_FINISHPAGE_RUN_PARAMETERS to pass in the parameters. Or you could create your own function using things like Exec, ExecWait, etc. and use MUI_FINISHPAGE_RUN_FUNCTION to call the function. (All info about these parameters are in the MUI help docs.)
Afrow UK
4th June 2009 11:47 UTC
I would recommend using ExecShell in a custom run function.
Stu
Panarchy
5th June 2009 00:03 UTC
Thanks Comperio, had to rename the file so it didn't have a space though... however, it now works :o
Thanks Afrow: I'll do research into that function