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 4589570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:05:49+00:00 2026-05-21T22:05:49+00:00

I’m trying to build an NSIS installer that will do the following: 1 When

  • 0

I’m trying to build an NSIS installer that will do the following:

1 When run normaly it will install the application with a installer with the usual choices.

2 When the installer is run with /S switch it silent installs, it’s ok if it shows UI. But it should be automatic.

It seems to me that the installer “works”, as it runs and then correctly starts the application again. But it has not updated anything, it’s almost as if it runs, but does not copy any files.

When it’s a silent install, it’s started by the following code ( Application updates itself)

    ProcessStartInfo Pro = new ProcessStartInfo();
    Pro.Verb = "runas";
    Pro.UseShellExecute = true;
    Pro.FileName = gDownloadedFileName;
    Pro.Arguments = "/S";
    Pro.WindowStyle = ProcessWindowStyle.Normal;
    Pro.CreateNoWindow = true;

NSIS script main ( I can post support scripts for NSIS that are custom if ppl desire )

; example2.nsi
;
; This script is based on example1.nsi, but it remember the directory, 
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install example2.nsi into a directory that the user selects,
!include MUI.nsh
!include fileassoc.nsh
!include Silent.nsh


!define _AppName "My application"
!define _AppExe "My application.exe"
!define _AppVersion "1.0.0.0"

;--------------------------------------------------------------------- Dont edit beloow

; The name of the installer
Name "${_AppName}"

; The file to write
OutFile "DFOInfo_Setup_beta.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\${_AppName}"

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\TheXSoft.com\${_AppName}" "Install_Dir"

RequestExecutionLevel admin

Function .onInit
  Call GetDotNet

  Call IsSilent
  Pop $0
  StrCmp $0 1 0 +3
    Call SilentInstall

FunctionEnd

Function GetDotNet
  IfFileExists "$WINDIR\Microsoft.NET\Framework\v4.0.30319\installUtil.exe" NextStep
  MessageBox MB_OK|MB_ICONEXCLAMATION "You must have the Microsoft .NET Framework 4.0 Installed to use this application. $\n$\n The installer will now open the Microsft .NET Framework 4.0 webpage$\n$\n$\n$\nRemember this program will not function until you have installed the .NET Framework 4 ( You will get a error message if you try to start it)"
  ExecShell Open "http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&displaylang=en" SW_SHOWNORMAL
  Quit
NextStep:
FunctionEnd

Section
SectionEnd
;--------------------------------

; Pages shown on none silent installer

;!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

# These indented statements modify settings for MUI_PAGE_FINISH

;If we want to display a run app function
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN_TEXT "Run ${_AppName}"
!define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN "$INSTDIR\${_AppExe}"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "French"


UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "${_AppName} (required)"
  SectionIn RO

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Put file there
  File /R "Current\*.*"

  ; Write the installation path into the registry
  WriteRegStr HKLM "Software\TheXSoft.com\${_AppName}" "Install_Dir" "$INSTDIR"

  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "DisplayName" "${_AppName} ( Remove only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "NoRepair" 1
  WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  SetShellVarContext all

  CreateDirectory "$SMPROGRAMS\${_AppName}"
  CreateShortCut "$SMPROGRAMS\${_AppName}\TheXSoft.com - Software page.url" "$INSTDIR\TheXSoft.com - Software page.url"
  CreateShortCut "$SMPROGRAMS\${_AppName}\GuildStats.NET - Get the stats for your MMO.url" "$INSTDIR\GuildStats.NET - Get the stats for your MMO.url"
  CreateShortCut "$SMPROGRAMS\${_AppName}\${_AppName}.lnk" "$INSTDIR\${_AppExe}" "" "$INSTDIR\${_AppExe}" 0

SectionEnd


;--------------------------------

; Uninstaller

Section "Uninstall"

  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}"
  DeleteRegKey HKLM "SOFTWARE\${_AppName}"

  ; Remove files and uninstaller
  Delete "$INSTDIR\*.exe"
  Delete $INSTDIR\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\${_AppName}\*.*"

  ; Remove directories used
  RMDir "$INSTDIR"

SectionEnd


;--------------------------------
; Silent install logic

Function SilentInstall
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Put file there
  File /R "Current\*.*"

  ; Write the installation path into the registry
  WriteRegStr HKLM "Software\TheXSoft.com\${_AppName}" "Install_Dir" "$INSTDIR"

  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "DisplayName" "${_AppName} ( Remove only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${_AppName}" "NoRepair" 1
  WriteUninstaller "uninstall.exe"


  SetShellVarContext all

  CreateDirectory "$SMPROGRAMS\${_AppName}"
  CreateShortCut "$SMPROGRAMS\${_AppName}\TheXSoft.com - Software page.url" "$INSTDIR\TheXSoft.com - Software page.url"
  CreateShortCut "$SMPROGRAMS\${_AppName}\GuildStats.NET - Get the stats for your MMO.url" "$INSTDIR\GuildStats.NET - Get the stats for your MMO.url"
  CreateShortCut "$SMPROGRAMS\${_AppName}\${_AppName}.lnk" "$INSTDIR\${_AppExe}" "" "$INSTDIR\${_AppExe}" 0

  Exec ${_AppExe}
  Quit
FunctionEnd
  • 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-21T22:05:50+00:00Added an answer on May 21, 2026 at 10:05 pm

    StrCmp $0 1 0 +3 is wrong, it should be +2 (+3 in this example is probably undefined behavior since you are skipping the hidden return instruction).

    Using relative jumps is error prone, you should use a label or rewrite it using the logic lib:

    !include LogicLib.nsh
    ...
    Function .onInit
      Call GetDotNet
    
      ${If} ${Silent}
        call SilentInstall
      ${EndIf}
    FunctionEnd
    

    But putting the silent install logic in a separate function doubles your work when the normal install logic is almost equal. You should be able to remove the SilentInstall function and just use a hidden section to execute during silent installs:

    Section "${_AppName} (required)"
    #shared install code
    SectionEnd
    
    Section "Start Menu Shortcuts"
    #shared startmenu code
    SectionEnd
    
    Section
    ${If} ${Silent}
        Exec ${_AppExe}
    ${EndIf}
    Section
    

    It is hard to say why your files are not updated, but if you use shared code you can run it without /S and check the detail log. My only guess is that InstallDirRegKey is picking up a non default installdir and you are looking at the wrong files. You can Process Monitor to monitor the install.


    Your code has some other unrelated issues:

    • RequestExecutionLevel admin is not enough, you need to deal with NT5 and NT6 with UAC off (UserInfo::GetAccountType)
    • You don’t have to specify the shortcut icon when the icon is the same as the target program
    • You should quote the path when calling Exec: Exec '"$instdir\${_AppExe}"'
    • Mixing UAC/runas/RequestExecutionLevel admin with Exec is problematic since you can end up running the program as the wrong user.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.