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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:51:03+00:00 2026-06-15T14:51:03+00:00

We currently package Bitfighter for Windows using NSIS, and (sometimes) manually create a separate

  • 0

We currently package Bitfighter for Windows using NSIS, and (sometimes) manually create a separate archive for running the game portably. I’m hoping to streamline the process to make building a portable version easier, thus encouraging us to do it regularly.

The current way we create our portable installs is to install the game normally (using the NSIS-built installer), then zip the install folder, and add a marker file called “portable.” I’d like to bypass the install step, and build the portable archive directly.

The main advantage of combining this with the NSIS installer is that it will streamline the build process, and will allow us to maintain a single list of files to be included.

Has anyone ever done anything like this?


In the end, I used a variation of the accepted answer, and used NSIS !ifdef directives to build two installers using the same codebase. By specifying /DPORTALBE, I will get a portable installer.

The code can be found in our Google Code repository.

  • 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-15T14:51:03+00:00Added an answer on June 15, 2026 at 2:51 pm

    Why not combine the normal and portable modes in one installer?

    !define NAME "foobarbaz"
    !define UNINSTKEY "${NAME}" ; Using a GUID here is not a bad idea
    !define DEFAULTNORMALDESTINATON "$ProgramFiles\${NAME}"
    !define DEFAULTPORTABLEDESTINATON "$Desktop\${NAME}"
    Name "${NAME}"
    Outfile "${NAME} setup.exe"
    RequestExecutionlevel highest
    SetCompressor LZMA
    
    Var NormalDestDir
    Var PortableDestDir
    Var PortableMode
    
    !include LogicLib.nsh
    !include FileFunc.nsh
    !include MUI2.nsh
    
    !insertmacro MUI_PAGE_WELCOME
    Page Custom PortableModePageCreate PortableModePageLeave
    !insertmacro MUI_PAGE_DIRECTORY
    !insertmacro MUI_PAGE_INSTFILES
    !insertmacro MUI_PAGE_FINISH
    !insertmacro MUI_LANGUAGE English
    
    
    Function .onInit
    StrCpy $NormalDestDir "${DEFAULTNORMALDESTINATON}"
    StrCpy $PortableDestDir "${DEFAULTPORTABLEDESTINATON}"
    
    ${GetParameters} $9
    
    ClearErrors
    ${GetOptions} $9 "/?" $8
    ${IfNot} ${Errors}
        MessageBox MB_ICONINFORMATION|MB_SETFOREGROUND "\
          /PORTABLE : Extract application to USB drive etc$\n\
          /S : Silent install$\n\
          /D=%directory% : Specify destination directory$\n"
        Quit
    ${EndIf}
    
    ClearErrors
    ${GetOptions} $9 "/PORTABLE" $8
    ${IfNot} ${Errors}
        StrCpy $PortableMode 1
        StrCpy $0 $PortableDestDir
    ${Else}
        StrCpy $PortableMode 0
        StrCpy $0 $NormalDestDir
        ${If} ${Silent}
            Call RequireAdmin
        ${EndIf}
    ${EndIf}
    
    ${If} $InstDir == ""
        ; User did not use /D to specify a directory, 
        ; we need to set a default based on the install mode
        StrCpy $InstDir $0
    ${EndIf}
    Call SetModeDestinationFromInstdir
    FunctionEnd
    
    
    Function RequireAdmin
    UserInfo::GetAccountType
    Pop $8
    ${If} $8 != "admin"
        MessageBox MB_ICONSTOP "You need administrator rights to install ${NAME}"
        SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
        Abort
    ${EndIf}
    FunctionEnd
    
    
    Function SetModeDestinationFromInstdir
    ${If} $PortableMode = 0
        StrCpy $NormalDestDir $InstDir
    ${Else}
        StrCpy $PortableDestDir $InstDir
    ${EndIf}
    FunctionEnd
    
    
    Function PortableModePageCreate
    Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
    !insertmacro MUI_HEADER_TEXT "Install Mode" "Choose how you want to install ${NAME}."
    nsDialogs::Create 1018
    Pop $0
    ${NSD_CreateLabel} 0 10u 100% 24u "Select install mode:"
    Pop $0
    ${NSD_CreateRadioButton} 30u 50u -30u 8u "Normal install"
    Pop $1
    ${NSD_CreateRadioButton} 30u 70u -30u 8u "Portable"
    Pop $2
    ${If} $PortableMode = 0
        SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
    ${Else}
        SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
    ${EndIf}
    nsDialogs::Show
    FunctionEnd
    
    Function PortableModePageLeave
    ${NSD_GetState} $1 $0
    ${If} $0 <> ${BST_UNCHECKED}
        StrCpy $PortableMode 0
        StrCpy $InstDir $NormalDestDir
        Call RequireAdmin
    ${Else}
        StrCpy $PortableMode 1
        StrCpy $InstDir $PortableDestDir
    ${EndIf}
    FunctionEnd
    
    
    
    Section
    SetOutPath "$InstDir"
    ;File "source\myapp.exe"
    
    ${If} $PortableMode = 0
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" "DisplayName" "${NAME}"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
        WriteUninstaller "$INSTDIR\uninstall.exe"
    ${Else}
        ; Create the file the application uses to detect portable mode
        FileOpen $0 "$INSTDIR\portable.dat" w
        FileWrite $0 "PORTABLE"
        FileClose $0
    ${EndIf}
    SectionEnd
    
    
    Section Uninstall
    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}"
    Delete "$INSTDIR\uninstall.exe"
    ;Delete "$INSTDIR\myapp.exe"
    RMDir "$InstDir"
    SectionEnd
    

    Or a simple version with no GUI support:

    !include LogicLib.nsh
    !include FileFunc.nsh
    !include Sections.nsh
    
    Section
    SetOutPath "$InstDir"
    ;File "source\myapp.exe"
    SectionEnd
    
    Section "" SID_CREATEUNINSTALLER
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" "DisplayName" "${NAME}"
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
    WriteUninstaller "$INSTDIR\uninstall.exe"
    SectionEnd
    
    Section Uninstall
    ;...
    SectionEnd
    
    Function .onInit
    ${GetParameters} $9
    ClearErrors
    ${GetOptions} $9 "/PORTABLE" $8
    ${IfNot} ${Errors}
        SetSilent silent
        ${If} $InstDir == ""
            StrCpy $InstDir "$Desktop\${NAME}"
        ${EndIf}
        !insertmacro UnselectSection ${SID_CREATEUNINSTALLER}
        SetOutPath $InstDir
        WriteIniStr "$InstDir\Config.ini" "Install" "Portable" "yes" ; Mark as portable install
    ${EndIf}
    FunctionEnd
    

    If you wanted to, you could probably create a setup that can generate the zip file: mysetup.exe /GENERATEPORTABLEPKG=c:\path\to\7z.exe and then the setup would extract the files, use ExecWait to call 7zip and then clean up and exit…

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

Sidebar

Related Questions

Currently I do the following: Create package using msbuild something.csproj /P:Configuration:Some /T:Package After that
I'm currently using the PAR Packer (pp) to package a couple of pl scripts
I'm currently attemping to display the progress of an SSIS package that's running on
We are currently running a Jenkins (Hudson) CI server to build and package our
To generate a NuGet package I'm currently using the command: nuget pack project.csproj -Prop
I am currently fiddling around with Node.JS to try to create a package for
I'm currently using the javax.script package for interpreting and executing Javascript code on the
I am currently using the WebClient in the Gargoylesoftware package and Apache Commons stuff..
I'm currently using PHP with the PEAR extension, as well as the Spreadsheet_Excel_Writer package.
I am trying to compile this libevent2 package to Windows, but currently I can't

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.