Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6818673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:12:30+00:00 2026-05-26T21:12:30+00:00

I am attempting to remove one more step in my application’s release process by

  • 0

I am attempting to remove one more step in my application’s release process by automatically retrieving versioning info from my executable (in this case, a .NET application).

Up to this point, I have been able to get by with a limited knowledge of NSIS, but I am quickly learning that this is not enough.

Step 1: Declare version info in executable

In AssemblyInfo.cs, I declare [assembly: AssemblyVersion("1.0.0.1")]. This successfully makes the version info appear in the compiled executable (under “File version” and “Product version”).

Step 2: Retrieve version info from executable

According to this article on “GetFileVersion”, importing “FileFunc.nsh” allows you to retrieve version info from an executable.

Code used:

Section
    Var /GLOBAL version
    ${GetFileVersion} "C:\test.exe" $version
    ...
SectionEnd

Step 3: Verify contents of function call

Based on section 5.1.7 of the documentation, I should be able to print to the command line during compile time using the “!echo” command. The difference between printing the contents of a variable (or a constant, etc) still confuses me, so I have tried all four of these options:

!echo $version
!echo "$version"
!echo "${version}"
!echo ${version}

This results in:

$version (InstallScript.nsi:15)
$version (InstallScript.nsi:16)
${version} (InstallScript.nsi:17)
${version} (InstallScript.nsi:18)

Step 4: Declare the installer metadata

Based on section 4.8.3, I should be able to add installer metadata via VIProductVersion and VIAddVersionKey.

VIProductVersion $version 
VIAddVersionKey "FileVersion" "$version"

In the built installer, this adds the string “$version” into the specified fields.


Is there a ToString() equivalent in NSIS? How can I access a variable’s contents? Does the print of the variable name mean that it has no contents? How can I verify that GetFileVersion is called correctly, executes correctly, and returns a value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:12:30+00:00Added an answer on May 26, 2026 at 9:12 pm

    Edit: NSIS v3 now includes a !getdllversion preprocessor instruction, you only need the GetVersionLocal workaround if you are still using NSIS v2.

    There are plans for a !getdllversionlocal in NSIS 2.47, for now you have to use this workaround:

    outfile test.exe
    requestexecutionlevel user
    
    !macro GetVersionLocal file basedef
    !verbose push
    !verbose 1
    !tempfile _GetVersionLocal_nsi
    !tempfile _GetVersionLocal_exe
    !appendfile "${_GetVersionLocal_nsi}" 'Outfile "${_GetVersionLocal_exe}"$\nRequestexecutionlevel user$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'Section$\n!define D "$"$\n!define N "${D}\n"$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'GetDLLVersion "${file}" $2 $4$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'IntOp $1 $2 / 0x00010000$\nIntOp $2 $2 & 0x0000FFFF$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'IntOp $3 $4 / 0x00010000$\nIntOp $4 $4 & 0x0000FFFF$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'FileOpen $0 "${_GetVersionLocal_nsi}" w$\nStrCpy $9 "${N}"$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'FileWrite $0 "!define ${basedef}1 $1$9"$\nFileWrite $0 "!define ${basedef}2 $2$9"$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'FileWrite $0 "!define ${basedef}3 $3$9"$\nFileWrite $0 "!define ${basedef}4 $4$9"$\n'
    !appendfile "${_GetVersionLocal_nsi}" 'FileClose $0$\nSectionend$\n'
    !system '"${NSISDIR}\makensis" -NOCD -NOCONFIG "${_GetVersionLocal_nsi}"' = 0
    !system '"${_GetVersionLocal_exe}" /S' = 0
    !delfile "${_GetVersionLocal_exe}"
    !undef _GetVersionLocal_exe
    !include "${_GetVersionLocal_nsi}"
    !delfile "${_GetVersionLocal_nsi}"
    !undef _GetVersionLocal_nsi
    !verbose pop
    !macroend
    
    !insertmacro GetVersionLocal "$%windir%\Explorer.exe" MyVer_
    VIProductVersion "${MyVer_1}.${MyVer_2}.${MyVer_3}.${MyVer_4}"
    VIAddVersionKey "FileVersion" "${MyVer_1}.${MyVer_2}.${MyVer_3}.${MyVer_4}"
    
    page instfiles
    section
    sectionend
    

    This macro:

    1. Creates a temporary .nsi file
    2. Compiles the temporary .nsi to a temporary executable
    3. Runs the temporary .exe
    4. Deletes the two files (.nsi and .exe)
    5. Returns an array containing the version info of the specified executable.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to remove accents from characters in PHP string as the first step
In attempting to remove all filenames not starting with a particular substring from a
I am encountering an issue when attempting to remove an object from my Core
So, am attempting to use one AdBannerView for my two views in an application
Im attempting to remove double quotes passed in a request parameter string. I know
I am attempting to remove dynamically created controls in C# 2008 asp.net The controls
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to implement a poor man's test of whether a process is still running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.