Archive: What Is Root Dir For NSIS Script?


What Is Root Dir For NSIS Script?
I'v never used nsis before and now I am using a script I've adapted from a sample install script I found on the web.

It seems I've done something wrong because it always aborts after failing to find an icon file which is clearly there.

If I change the icon address from the MUI thing and instead write in a string with the full path: C:\myprog\myprogicon.ico it find the icon file alright and processes it and moves on... only to fail a little further for an identical reason.

So it seems to me that path is the problem. Somehow the right path is not defined.

Is this right? Could this be it? How do I properly set it or define those MUI things or whatever to make it work?

Here's the last part of the NSIS log of the failure:



!define: "myprog_INSTALLDIR"="myprog"
!define: "myprog_EXENAME"="myprog"
Name: "My Little Progr"
OutFile: "myprog_win32_installer.exe"
InstallDir: "$PROGRAMFILES\myprog"
InstallRegKey: "HKCU\Software\myprog\"
SetCompressor: lzma
ShowInstDetails: show
ShowUninstDetails: show
Var: "StartMenuFolder"
!define: "MUI_ICON"="myprog\myprogicon.ico"
!define: "MUI_WELCOMEPAGE_TITLE"="Install Myrpog"
!define: "MUI_WELCOMEPAGE_TEXT"="Myprog is a free open source prog written in the python programming language, available under the terms of the GNU General Public License.

!insertmacro: MUI_PAGE_WELCOME
Error while loading icon from "myprog\myprogicon.ico": can't open file
Error in macro MUI_INTERFACE on macroline 64
Error in macro MUI_PAGE_INIT on macroline 3
Error in macro MUI_PAGE_WELCOME on macroline 5
Error in script "C:\myprog\myprog_install_script.nsi" on line 62 -- aborting creation process


The root dir for an nsis script is the directory where the nsis script is stored. So if your script is C:\Projects\YourProject\YourScript.nsi, the compiler will be looking for the ico file in C:\Projects\YourProject\myprog\myprogicon.ico. Note that the installer icon location is a compiletime specification (requiring a compiletime path as I explained), while icon locations for start menu/desktop shortcuts are runtime specifications (requiring a runtime path such as $INSTDIR\icon.ico).


Thank you very much for your reply.

That's what I thought would be the case. You can see from the last line of the output where the script is:

Error in script "C:\myprog\myprog_install_script.nsi" on line 62 -- aborting creation process

So I copied the script into C:\ and ran it from there.

Thinking it should then look in C:\myprog for the icon and all other files, which is where they are.

But:

No better. Exactly the same result. That's when I was stumped and turned to the web and forums and here...

:(

p.s.

Here's the full output except I've cut out most of the long list of included "plugin.dlls"


MakeNSIS v2.46 - Copyright 1995-2009 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.

Processing config:
Processing plugin dlls: "C:\Program Files\NSIS\Plugins\*.dll"
- AdvSplash::show
ialHangup
- Dialer::AutodialOnline
- Dialer::AutodialUnattended
-

- nsExec::Exec
- nsExec::ExecToLog
- nsExec::ExecToStack

!define: "MUI_INSERT_NSISCONF"=""

Changing directory to: "C:"

Processing script file: "C:\myprog_install_script.nsi"
!include: "C:\Program Files\NSIS\Include\MUI2.nsh"
!include: "C:\Program Files\NSIS\Contrib\Modern UI 2\MUI2.nsh"
NSIS Modern User Interface version 2.0 - Copyright 2002-2009 Joost Verburg (C:\Program

Files\NSIS\Contrib\Modern UI 2\MUI2.nsh:8)
!define: "MUI_INCLUDED"=""
!define: "MUI_SYSVERSION"="2.0"
!define: "MUI_VERBOSE"="3"
!include: closed: "C:\Program Files\NSIS\Contrib\Modern UI 2\MUI2.nsh"
!include: closed: "C:\Program Files\NSIS\Include\MUI2.nsh"
!define: "myprog_NAME"="myprog"
!define: "myprog_VERSION"="1.2.1"
!define: "myprog_INSTALLDIR"="myprog"
!define: "myprog_EXENAME"="myprog"
Name: "myprog"
OutFile: "myprog-1.2.1_win32_installer.exe"
InstallDir: "$PROGRAMFILES\myprog"
InstallRegKey: "HKCU\Software\myprog\"
SetCompressor: lzma
ShowInstDetails: show
ShowUninstDetails: show
Var: "StartMenuFolder"
!define: "MUI_ICON"="myprog\myprogicon.ico"
!define: "MUI_WELCOMEPAGE_TITLE"="Install myprog"
!define: "MUI_WELCOMEPAGE_TEXT"="myprog is a free open source prog."


!insertmacro: MUI_PAGE_WELCOME
Error while loading icon from "myprog\myprogicon.ico": can't open file
Error in macro MUI_INTERFACE on macroline 64
Error in macro MUI_PAGE_INIT on macroline 3
Error in macro MUI_PAGE_WELCOME on macroline 5
Error in script "C:\myprog_install_script.nsi" on line 62 -- aborting creation process

==========================

I wonder where can I see these macros to check them out if that'd help?

I've googled and I've seen there's tons - tons - of help with nsis. Unfortunately there's too much! I can't make my way through it. I can't distinguish which bit it is I want to find the answers I want. Every page I went to had an alphabetical breakdown of sub-subjects and left me floundering as to which one to look in.
Looking in a few likely ones just left me with a headache, didn't provide the answer.

I was hoping this script was a basic template and I could just alter it to suit but it is not working out like that.

Could you direct me to a basic, totally stripped down, template that i can use like that? To make the most basic of installers just as a starting point?


Originally posted by jepboro
Could you direct me to a basic, totally stripped down, template that i can use like that? To make the most basic of installers just as a starting point?
That would definitely be NSIS\Examples\Example1.nsi and Example2.nsi. Use the command reference to find out what the commands do: http://nsis.sourceforge.net/Docs/Chapter4.html

As for the icon problem, you shouldn't put anything in C:\, because the root directory of your boot drive is special. Just like you shouldn't put anything in c:\Windows, etc. Anyway, if the compiler says it cannot open the icon file, then it probably cannot open the icon file. Either the file is locked (icon editor?) or the file doesn't exist (wrong filename?).

Makensis works relative to where the script being built is. It has nothing to do with the root. If your icon is in the same folder as the script then you just specify the icon file name.

Stu


Originally posted by Afrow UK
Makensis works relative to where the script being built is. It has nothing to do with the root. If your icon is in the same folder as the script then you just specify the icon file name.
Yeah, what he meant by 'root' was just the working dir.

Yep, that's right. I meant the working dir, sorry.

The file does exist. I mentioned that when I gave the precise path it found the file okay - oh, well, didn't complain about the file at all.

and I can click on the file and have it open and show an icon, so that's okay.

Thanks for the clues on a 'basic' script and such. I'll check it all out. I did find two basic scripts, perhaps even they were the ones you point to, and they didn't solve the problem for me because of being too different to the one I started with. Which, I think I mentioned, I cut and pasted and modified to suit my own prog.

Looks like I am going to have to do the hard yards, get down to it and figure out what each part of the script is really about and what is needed and what isn't... suss it all out, learn something.

I've been trying to get out of it easily and its not working.....

Actually I've sort of been looking for an nsis page that says something like "To make an installer for your exe file "yourfile.exe" just replace every occurrence of 'ourfile.exe' in the following script with 'yourfile.exe'

But I guess it simply cannot be that simple. Virtually everything you write for windows has dependencies nowadays, I suppose and single standalone .exe files are rarer and rarer. A prog that catered to them would be catering to a niche market I guess...

I'll go see if I can actually do some thinking.... ouch....

thanks for the help

:)

p.s. Shouldn't put anything in the C: root dir? Then a 3.7Gig C:\ dir with 1,127 objects would be sort of going the wrong way?


Originally posted by jepboro
The file does exist. I mentioned that when I gave the precise path it found the file okay - oh, well, didn't complain about the file at all.
Well like I said, if the compiler cannot open the file, then it probably cannot open it for some reason. For your icon problem, that's all you have to figure out. The rest of the nsi script doesn't have much to do with this.

Originally posted by jepboro
p.s. Shouldn't put anything in the C: root dir? Then a 3.7Gig C:\ dir with 1,127 objects would be sort of going the wrong way?
Uhm... Yeah, that would indeed be quite wrong. I would suggest putting it in a subdirectory.

It's alright. I am getting somewhere now. I had to write the full pathname for that 'file' thing just as I had to for the icon thing and then it raced away, doing its thing. Manufactured an install .exe, even. Doesn't work properly but I think I know why that is. I just couldn't understand why nsis couldn't find those files and I still don't know, but I don't care right now, horse before the cart, let me get on with producing the .exe and a viable installer for it, that's all.

thanks a lot for your help, all.

I might move that c: collection to a subdir but, apart from an increasing hassle finding things I've put there, I see no disadvantage in having a full root dir. What problem do you see, in fact, or is it just a 'neatness' thing?


I see no disadvantage in having a full root dir
Well, one problem I'm aware of is that if the root dir gets too full the computer won't boot, saying "NTLDR is missing". Even deleting files at that time doesn't cure that problem.

People here at work occasionally have unzipped our project to the root of their computer (25000 files in that zip) and that's the result. It can be repaired, but needs a special program on a bootable cd to fix. Microsoft thinks they've fixed it (see http://support.microsoft.com/kb/320397) but we still have the problem.

Well that's a valid point if I get nearly 25000 entries. But until then...

On the side of having many things in the c dir it can be said that much goes there by default so you don't have to fight against the tide and, secondly, it is handy to have things in one heap, it makes for easier searching.

I've also got another 600gig or so of directories and files and searching for stuff on C:, annoying though I often find it, is easier than searching through all that lot.

There's a 'filing clerk' skill required that I don't seem to have in any great measure...

:)


yes that cool


I never use Windows search due to the fact that I store everything in a folder tree. Each installer has its own folder and sub folders. You sound like my dad who's filled up my old computer with crap because he doesn't know how not to :p He's generally very untidy in real life too...

I suppose though from using computers at an early age I've been able to learn how to organise stuff. It's too late for some though lol

Stu


Yes, I'm probably even older than your dad.... It might not be quite as simple as you think, though. You've been with computers all your life, you say, and that's perhaps pertinent - you've got no life before computers, me and your dad, we do.

We've got a whole life prior to your life and 'leftovers' and things pertinent to it that we keep. On the computer, in drawers, in boxes, in the shed....

'We' probably keep a whole swag of things just for you - been keeping things for the kids since they were babies - 'Here's your bag, it was where you left it..', here's this, here's that...

And right here on my computer things ain't as bad as perhaps they sound. Sequoia shows me the situation in overview and I check it out quite frequently. 80% of my C: dir drive is My Documents and Program Files.

There's 387 objects in my Program Files and that means more than 300 installed programs, doesn't it? And that's a reflection of my wide ranging interests and a trail back through time showing how those interests have wandered around.

The internet, mate, is the most wonderful thing ever happened to the working people of the world, the 'peasants' of the world. We've got more there than ordinary people have ever, ever had. We are immeasurably rich with access to knowledge and abilities..... I've been chasing around in that space besides myself with glee ever since it began (that space), before it began (the internet), just chasing around inside a computer. Picking up riches here and there and everywhere and keeping many of them.

I knew a guy perhaps like yourself, had the neatest hard drive I've ever seen. He was ruthless and swift deleting temp files and dirs and uninstalling progs he no longer used and deleting data no longer used. He kept no history. He did no 'task switching' - he was interested in only one thing at a time.

He never kept anything for its own sake. Had no other interest except the job in hand.

It's a bit like a picture, you see, a painting. I'm painting a rich picture with thousands of colours and shades of colour and entities.... or perhaps a richly woven tapestry might be a better analogy...


That guy painted a primary coloured picture like a cartoon, without shades and anything unnecessary.... That's his bag, that was his bag, his way of doing it.

My Documents is 70gig of pictures and videos created myself, stock-in-trade, so to speak (not really, I don't 'trade') stuff I work with making dvd's for the family and is like the old time 'family album' but much, much richer than any family album ever existed in the old days.

It's a work. It's a storehouse. It's a wonder. How young are you? Too young to know about kids, babies? Then you wouldn't be aware of the importance, the significance, of keeping these memories, how valuable they are to so many people, self included.

My whole computer is a work, a storehouse, a wonderland... I guarantee a person who chose could wander around in my computer, investigating here and there, following this trail and that, and never come out and be totally occupied and satisfied for years - years, that's how much stuff is in there.

It is a bag of tools. It is a bag of toys. It is a theatre and a sound stage, a school... a pile of materials waiting to be used... There's 200gig of movies on the E: drive. There's a terabyte of backup storage on the I: drive. There's what was once a whole computer on the F: drive (I mean, that's the only disk that computer had and now it's here just as it was )

There's programmes on my computer that I wrote back in 1987 - possibly before you were even alive. Programmes in Cobol and Fortran. No there's not. I'm a liar. I just took a look and they're not there. Sorry. But I know where they are I think. In the box of old hard drives I have (can you believe a 100Meg hard drive? How about 40Meg?). That's part of the 'mess', I thought I had all them carefully preserved and copied again and again onto each new drive and still existing on these drives now. Apparently not. But there's progs written '90 in Clipper and xBase. Perhaps before you were born. You've had computers all your life, you say, we've had computers all your life and before....


And, of course, nothing to do with it being a full, wonderfully messy (perhaps) computer, but just because it is also an ordinary computer, it has access to the internet, the whole world, all those online people... like now... adding to the riches of it.......

When I was a kid we had the backyard and the street. Not even television. Not even a motor car in our family. Books from the library only....

I'm very happy with my computer and the way it is organised even if i do have to hunt around a bit sometimes - well, especially because I have to rummage around a bit sometimes....

talk a bit too much sometimes, don't I?

:)


Sure I can believe a 40Meg harddrive. Can you believe 5? Not everyone's as young as you may think. :)

Interesting story, albeit it rather beside the topic at hand, and as much as I can admire your appreciation of the possibilities of PCs, there's one thing I'd like to point out in relation to it: There are also a lot of impossibilities. Having some experience with how non-geeks use their computers, I can surmise from the way you describe your PC that you're playing a rather risky game. You cannot trust PCs. It's all well and good, until they blow up in your face. And there is one thing that becomes exceedingly difficult with increasing messiness of your PC: Making backups. It's something worth considering.