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

  • SEARCH
  • Home
  • 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 7876763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:13:09+00:00 2026-06-03T03:13:09+00:00

In NSIS Script Language I get an error when I go access a global

  • 0

In NSIS Script Language I get an error when I go access a global variable from within a macro.

Is my variable installDirectory truely global? How can I set the variable installDirectory from within a macro or function(if its possible within a function)?

var installDirectory

!macro IdentifyDir
   IfFileExists C:\test\9.00\ Version9 AbortInstall

   Version9:
      $installDirectory "C:\test\9.00\"
   AbortInstall:
      Abort
!macroend

Also can a Macro &/or function return a value in NSIS(or shd I just use push/pop)?

!macro IdentifyDir
   IfFileExists C:\test\9.00\ Version9 AbortInstall

   Version9:
      return "C:\test\9.00\"
   AbortInstall:
      Abort
!macroend

var installDir !insertmacro IdentifyDir # is that valid?
  • 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-06-03T03:13:10+00:00Added an answer on June 3, 2026 at 3:13 am

    There are two issues :

    • to assign a variable, you miss one assignment instruction; for a string variable you can use StrCpy : StrCpy $installDirectory "C:\test\9.00\"

    • as stated in your another question about labels, labels are not subs but only some defined points that can be reached by flow control, thus when jumping to the Version9 label, without another jump the execution will run to the Abort statement that follows the the AbortInstall label. You should either put another label like end_of_macro: before the the !macroEnd statement and add a goto before the AbortInstall label (beware that that the macro is expanded where you put the !insertMacro so you must choose a unique label name, it is not like for sections or functions) or (more elegant) invert the two labels : in the case of the abort the execution will stop there and in the second case it will continue outside of the macro

    !macro IdentifyDir 
        IfFileExists C:\temp\9.00 Version9 AbortInstall
    AbortInstall:
        Abort
    Version9:
        StrCpy $installDirectory "C:\test\9.00\"
    !macroend
    

    For your question concerning the return value, you can use the default registers $0 to $9 and $R0 to $R9

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming that it is possible to compress a file from within an NSIS script,
Can a NSIS script download .NET and DirectX from microsoft, then install it? I
From an NSIS script (located at C:\nsis\ for example), I execute an external program
I have a simple NSIS script with a directory page, where the user can
In my NSIS script, the MUI_STARTMENU_GETFOLDER macro is not working as expected - instead
Can I start a service on remote machine using NSIS script. I know we
How do I check from within my NSIS installer if my installer has the
I'm writing an install script utilizing the NSIS installer scripting language. I have a
I need NSIS script witch download file from the internet and execute it. I've
Is it possible to import nsis code and run it from within a compiled

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.