Archive: New User Questions (2 of them)


New User Questions (2 of them)
First off, thanks for your time.

Question #1: How do I get the /oname argument to work correctly?
Here is my source

GetTempFileName $R1
SetOutPath $INSTDIR ;Temp Directory
File /oname="$R1 h:\path\filename.exe"

When executing this I get an "error writing to file:" and it lists the temp path twice. Example: "c:\temp"c:\temp\nst64.tmp" I believe this is because the $R1 variable includes the entire path as does the $INSTDIR but am not sure. If so, what is the cleanest way to get just the tempfilename without the full path?

Question #2: How can one modify the executable header info from NSIS? I'd like to be able to change the version info, copyright info, etc. and have no idea how to do so.

Your response is greatly appreciated. Thanks.

Steve Behrns


Re: New User Questions (2 of them)

Originally posted by Steevo

Question #2: How can one modify the executable header info from NSIS? I'd like to be able to change the version info, copyright info, etc. and have no idea how to do so.

Your response is greatly appreciated. Thanks.

Steve Behrns
Try setting the BrandingText. That will change the text at the bottom of the installer. As far as I know that the only place that NSIS is even mentioned. I'm not sure what you mean by copyright info?

Rereading my post I think I was unclear. When viewing the properties of most Win32 executables there is a Version tab that includes information like Company Name, File Name, Internal Version, etc. Once the executable is compiled that information is not changeable. I was wondering how to modify this information from within an NSI script if possible--prior to compilation.

Thanks.


Originally posted by Steevo
Rereading my post I think I was unclear. When viewing the properties of most Win32 executables there is a Version tab that includes information like Company Name, File Name, Internal Version, etc. Once the executable is compiled that information is not changeable. I was wondering how to modify this information from within an NSI script if possible--prior to compilation.

Thanks.
It's not possible from a script because the exehead has already been compiled and the info would be stored in there. You could easily recompile the exehead with this info just by editing the resource file.

The /oname doesn't work becasue of the quotes... You are telling NSIS that the output name should be "$R1 h:\path\filename.exe", but I think you want is that the output name will be $R1 and the file to extract is h:\path\filename.exe.

It should look like this:
File /oname=$R1 h:\path\filename.exe


The only way to change header information is to use resource editors .. you can use either PE Explorer (www.heaventools.com/) or Resource Hacker (www.rpi.net.au/~ajohnson/resourcehacker/) !


Originally posted by veekee
The only way to change header information is to use resource editors .. you can use either PE Explorer (www.heaventools.com/) or Resource Hacker (www.rpi.net.au/~ajohnson/resourcehacker/) !
If you do that, you need to make sure that you are not using the CRCCheck or it will fail.

Just add a resource with the version info and recompile.


"It's not possible from a script because the exehead has already been compiled and the info would be stored in there. You could easily recompile the exehead with this info just by editing the resource file."

"Just add a resource with the version info and recompile."

ok, i've used resource hacker a million times, but these replies don't make any sense. what resource file? i mean, got any examples laying around? cuz i sure can't get this to work.

versioninfo should definitely be an option that can be called from your script (somehow).

i would like to see an example for nsis. i've had to make versioninfo resource files in older versions of delphi, but the replies i'm seeing for doing this in nsis are so vague that it's impossible to determine how to do it.

thanks!


The easiet way would be compiling NSIS with dummy version info and then changing it using Resource Hacker while compiling the script using this kind of command:

!packhdr tmp.dat '"C:\program files\reshacker\res.exe" tmp.dat'

If you don't have a compiler you'd have to add the version info manually. You'd have have to use the same command but a different method in the resource editor. The resource editor help should say something about adding resources.

versioninfo should definitely be an option that can be called from your script (somehow).
It's in the todo list.

hmm. good info, but still no hardcore examples. ok, here's is my best effort so far, and it still failed.

i didn't know the correct info for the versioninfo resource, so i found a delphi exe that i made that does have a version tab.

i used resource hacker to extract the versioninfo resource to a file on my desktop. the contents:

1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "Whatever, Inc."
VALUE "FileDescription", "Blah RC1"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", ""
VALUE "ProductName", ""
VALUE "ProductVersion", "1.0.0.0"
VALUE "Comments", "Created by [SoD]Sgt-D"
}
}

BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04E4
}
}

ok, looks good, right? so now i open my nsis exe in resource hacker and tell it to add in a new resource, from the file i saved on my desktop.

resource type = version info
resource name = 1
resource language = 1033

resource hacker shows everything 100% identical to my delphi exe, so it should work fine. when i save the new exe, nothing. no version tab. i even tried modifying the information and clicking the "compile script" button.

no matter what i try, it never creates the version info tab.

if this really is the easiest way, then i'm screwed. :(


Which file exactly did you edit with Resource Hacker? If you use this line:
!packhdr tmp.dat '"C:\program files\reshacker\res.exe" tmp.dat'
And save NSIS will use the new EXE header. Make sure Resource Hacker really does add the information (find tmp.dat, rename it to .exe and check for the version tab).


bah, i have no idea how to put "dummy" version information into my nsis script, or i don't know what you mean by that comment. i don't have a compiler, just nsis... so i'm not sure what "You'd have have to use the same command but a different method in the resource editor" - again, too vague. i've read the resource hacker help file for adding and extracting resources, seems to work fine... like test.rc. so i don't know where tmp.dat is coming from in "!packhdr tmp.dat ...". i tried writing a basic nsis script use your command...

!packhdr tmp.dat '"C:\program files\reshacker\res.exe" tmp.dat'

i even tried substituting test.rc in place of tmp.dat. during nsis compile it shows the main resource hacker screen, with none of my versioninfo, then when i close resource hacker it systematically deletes my test.rc file and i get a new exe with no version tab.

unless someone has a good example i'm just going to drop it. as far as i can tell, despite suggestions in this forum, there really is no "easy" way to do this, and certainly no examples of it anywhere. maybe the version info (from the todo list) will be added to scripts sometime soon! ;)


I am happy to declare you as the first example I have ever seen :)

Lets start from the begining (ignore the compiler note and the dummy and easiet way). !packhdr tells NSIS to dump the EXE header to a certain file (tmp.dat in the above case) and then calls the program in the second parameter. This program can do whatever it wants with the EXE header, in your case it should add a version resource. After the program exits NSIS will read the edited EXE header and use it instead of the old one.

The only part you should handle (besides adding that command to the script) is the addition of the resource to the EXE header, and that you have already done according to you. Just don't forget to save ;)

I hope that's a bit more clear now :)


ok, i think i totally understand you now. but i'm still having problems. remember the sample version info resource i showed earlier? i just grabbed an old exe, i even tried a windows xp exe, and i used resource hacker to extract the resource - just for version info. here's a sample:

1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", ""
VALUE "FileDescription", "VersionInfo Test #1"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", ""
VALUE "ProductName", ""
VALUE "ProductVersion", "1.0.0.0"
VALUE "Comments", ""
}
}

BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04E4
}
}

now i should be able to manually add that resource to any exe or dll that i want to, right? well, i can add it to every file on my hard drive, and i can save the new file with the resource inside (it looks 100% correct by the way) --- but when i right click the new exe, no version tab.

i tried exporting the resource as a text file and also as a binary flie, but if i can't use resource hacker successfully add a version tab, i will never get it to work right from my nsis script.

if someone can help with getting it to work manually so that i can display a version tab, i will gladly submit my nsis command line that can automatically add the resources for you.

thanks!


I have been playing around with Resource Hacker and finally found the exact way to do this (docs didn't help much =/):

1) Open a DLL/EXE with a version resource
2) Click on the version resource
3) Action->Save Resource as a *.res file ...
4) Save it somewhere
5) Open your EXE (with !packhdr in our case)
6) Action->Add a new Resource ...
7) Choose the file you have just exported from the last EXE/DLL
8) Chooes the version info resource in the dialog
9) Edit the newly added resource
10) Done! :D


heh, yeah, i just saw "save as .res" and came back to post a little message about finally successfully getting a version tab. thanks for the help. ;)


A sample script to add Version tabs to your NSIS Installer Executables!

This is a fully automatic method which can be implemented seamlessly into all of your NSIS scripts to automagically add Version Tabs for your installers!

See the attachment for more information. :)

-sgt


Nice... How about creating an archive (http://nsis.sf.net/archive) page for it so anybody can track it down easily?


Maybe I'm wrong :p but It doesn't for me on my XP:
this is the code:


!define ResDir "C:\JOELITO\utilidades\NsisRes"
!packhdr tmp.dat '"${ResDir}\ResHacker.exe" -addoverwrite tmp.dat, tmp.dat, ${ResDir}\test.res, versioninfo,1,'

Is it right? :weird:

!define ResDir "C:\JOELITO\utilidades\NsisRes"
!packhdr tmp.dat '"${ResDir}\ResHacker.exe" -addoverwrite tmp.dat, tmp.dat, ${ResDir}\test.res, versioninfo,1,'
test.res isn't in your ResHack folder - so use test.res, not ${ResDir}\test.res

does that fix it?

Nice... How about creating an archive (http://nsis.sf.net/archive) page for it so anybody can track it down easily?
VIT - Version Info Tabsheets for NSIS

I am attaching the ZIP to this forum because I couldn't find a way to add it to the new Archive page.

Thanks everyone for all of the help today... it finally paid off!

:)

Nop, :(
I'll try another ways :)


!define ResDir "C:\JOELITO\utilidades\NsisRes"
!packhdr tmp.dat '"${ResDir}\ResHacker.exe" -addoverwrite tmp.dat, tmp.dat, ${ResDir}\test.res, versioninfo,1,'
hmm, without the define, does this work?:

!packhdr tmp.dat '"C:\JOELITO\utilidades\NsisResResHacker.exe" -addoverwrite tmp.dat, tmp.dat, test.res, versioninfo,1,'

also, you might want to grab VIT.ZIP as mentioned in my previous post. it's better than the versioninfo.zip i posted earlier. it has updated info and might i made it a little easier to follow.

Wouldn't it be simple to add an instruction to NSIS that tells the compiler that it has to take the specified .res-file and set the version information with it?

AltVersionInfo "${NSISDIR}\Contrib\AltVersionInfo\template.res"

Originally posted by virtlink
Wouldn't it be simple to add an instruction to NSIS that tells the compiler that it has to take the specified .res-file and set the version information with it?
AltVersionInfo "${NSISDIR}\Contrib\AltVersionInfo\template.res"
god... wouldn't that be awesome! ;)

Agree with you virtlink :up:


what would make that even better is if we could type the version info in normal text and nsis could convert it to the binary res file... that way nobody would have to rely on resource hacker.


Yes VirtLink, it's simple. Try it and you'll see.

It's on the todo list.


In one moment of thinking :weird:
How does Nsis "embed" the XP Manifest in the installer?
Maybe I'll be the same with the .res information, isn't?


The NSIS compiler has a resource updater that handles all resource updated. Useles dialog resources are also being removed using this updater.


i'd like to know how to use it ;(


You can't. It's code inside makensis which is invoked for very specific reasons during compilation. For example, your installer only uses some of the page types so makensis decides you don't need the resources for the others and removes them. Or you turn XPStyle on, makensis adds an XP manifest into your installer binary. The code that does these things is not available to you directly.

If you are still interested in the code look in CVS or your NSIS folder at source/ResourceEditor.cpp.