The first line where I want to extract a file called backend.tar.gz is not working correctly. I want to extract this folder while installing. The folder is inside INSTDIR (installation directory). May I know what am I doing wrong?
installer.nsh
!macro customInstall
ExecWait '$SYSDIR\cmd.exe /c ""$INSTDIR\resources\assets\bsdtar.exe" -xzvf "$INSTDIR\resources\assets\backend.tar.gz" -C "$INSTDIR\resources\assets\""'
ExecWait '"$INSTDIR\resources\assets\msvc_redistributable.exe" /passive /norestart'
!macroend
package.json nsis config
"nsis": {
"installerIcon": "assets/resources/builder/icon.ico",
"uninstallerIcon": "assets/resources/builder/icon.ico",
"installerHeaderIcon": "assets/resources/builder/icon.ico",
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"include": "nsis/installer.nsh"
}
I tried using ExecWait without cmd but that does not work either.
Related
Electron-Builder Version:
22.14.5
Node Version:
16.15.1
Electron Version:
18.3.0
Electron Type (current, beta, nightly):
current
Target:
win nsis ia32
based on this PR #1173
Hi, based on this feature, it seems there is an issue to interact with the unwelcome page.
by default when we use electron builder with nsis, we have now during the uninstallation , the unwelcome page and the unfinish page like you described bellow. And it's cool
but we didn't interact with them like this
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.custom_pre_page
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.custom_leave_page
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEPAGE_TITLE 'unwelcome_title'
!define MUI_WELCOMEPAGE_TEXT 'unwelcome_text'
!insertmacro MUI_UNPAGE_WELCOME
so when we have are in a language where the default text is too long we don't have the 3 lines.
and we can't change the text. see the screenshot.
I've test many ways to solve it, manage anothe unpage welcome and it works for the othe page but the default page that you added is never removed.
I tried to manipulate the window item to hide it, try to click on the next button with a command to navigate
but it doesn't work. And I verified that handles are correct.
so what it the solution in this context to interact with your unwelcome page or to remove it?
thanks in advance
Electron-Builder Version:
22.14.5
Node Version:
16.15.1
Electron Version:
18.3.0
Electron Type (current, beta, nightly):
current
Target:
win nsis ia32
based on this PR #1173
Hi, based on this feature, it seems there is an issue to interact with the unwelcome page.
by default when we use electron builder with nsis, we have now during the uninstallation , the unwelcome page and the unfinish page like you described bellow. And it's cool
but we didn't interact with them like this
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.custom_pre_page
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.custom_leave_page
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEPAGE_TITLE 'unwelcome_title'
!define MUI_WELCOMEPAGE_TEXT 'unwelcome_text'
!insertmacro MUI_UNPAGE_WELCOME
so when we have are in a language where the default text is too long we don't have the 3 lines.
and we can't change the text. see the screenshot.
I've test many ways to solve it, manage anothe unpage welcome and it works for the othe page but the default page that you added is never removed.
I tried to manipulate the window item to hide it, try to click on the next button with a command to navigate
but it doesn't work. And I verified that handles are correct.
so what it the solution in this context to interact with your unwelcome page or to remove it?
thanks in advance
https://github.com/electron-userland/electron-builder/issues/6987
screenshot
after searched deeper,
I can see in the electron-builder code (after cloning the repo) that the assistedInstaller.nsh
managed the uninstaller as is
...
!else
!insertmacro MUI_UNPAGE_WELCOME
!ifndef INSTALL_MODE_PER_ALL_USERS
!insertmacro PAGE_INSTALL_MODE
!endif
!insertmacro MUI_UNPAGE_INSTFILES
!ifmacrodef customUninstallPage
!insertmacro customUninstallPage
!endif
!insertmacro MUI_UNPAGE_FINISH
!endif
the !insertmacro MUI_UNPAGE_WELCOME is added without condition whereas the customWelcomePage is added with a condition.
I guess it's the root cause of my problem.
If I try to add a custom unwelcome page like this
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
Var mycheckbox ;
Function un.ModifyUnWelcome
${NSD_CreateCheckbox} 120u -18u 50% 12u "Clean Configuration"
Pop $mycheckbox
SetCtlColors {MUI_BGCOLOR}
${NSD_Check} $mycheckbox ; Check it by default
FunctionEnd
Function un.LeaveUnWelcome
${NSD_GetState} $mycheckbox $0
${If} $0 <> 0
MessageBox MB_TOPMOST 'We remove configuration'
${EndIf}
FunctionEnd
I have my custom unwelcomePage, but when click on next I go to the second unwelcome page placed in the assistedInstaller.nsh
And I have no ways to change this file.
if someone knows how to manage this file. I guess that I must rebuild electron-builder with a change for that but It will be better that electron-builder team fix the problem isn't it?
Finally I Proposed a fix, and the fix was accepted and pushed to the version 23.0.6
Now you have just to update your nsis part in your package.json adding the field removeDefaultUninstallWelcomePage to true as bellow:
"nsis": {
...
"removeDefaultUninstallWelcomePage": true
},
And add the macros on your nsh file:
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
!define MUI_WELCOMEPAGE_TITLE_3LINES
!insertmacro MUI_UNPAGE_WELCOME
And you have just to add your custom code on the show and leave part.
I'm writing a script to associate file associations, and I'm wondering if it's possible to assign a variable to HKLM or HKCU depending on whether it's an admin or user install. The project I'm working on determines this at run time when the user appends -user for a user install as opposed to an admin install. I was thinking of something like:
Var location
${If} $InstallMode == "Admin"
$location = HKLM ;probably not the right way to assign
${Else}
$location = HKCU
${EndIf}
I'm new to NSIS and from what I've read and tried so far, I can !define a variable to be HKLM or HKCU by writing !define location HKCU but define won't work during runtime.
SHCTX exists for this purpose. It is controlled by SetShellVarContext. The default is the user (HKCU), set to All for HKLM.
I'm working on a windows 10 app but I've noticed that when I uninstall it it's icon remains in the notification & actions window. what would I need to do or add to my uninstaller to allow it to remove this icon. This is what what uninstaller look like in my .nsi script
Section "Uninstall"
Call un.XXXXXXXXX
ExecWait '"$INSTDIR\f2p_ping.exe" --f2p' $0
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "MyApp"
DeleteRegKey HKLM "SOFTWARE\MyApp"
DeleteRegKey HKCU "Software\MyApp\Overlay\ExcludedProcesses"
DeleteRegKey HKCR "MyApp"
RMDir /r "$INSTDIR"
RMDir /r $PROGRAMFILES\MyApp
RMDir /r "$APPDATA\MyApp\*.*"
; Remove shortcuts, if any
SetShellVarContext current
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
SetShellVarContext all
Delete "$SMPROGRAMS\MyApp\*.*"
Delete "$SMPROGRAMS\Startup\MyApp.lnk"
Delete "$DESKTOP\MyApp.lnk"
; Remove directories used
SetShellVarContext current
RMDir "$SMPROGRAMS\MyApp"
SetShellVarContext all
RMDir "$SMPROGRAMS\MyApp"
RMDir "$INSTDIR"
SectionEnd
The best solution is probably to have your application hide the notifications since it already contains notification code. Run something like ExecWait '"$InstDir\MyApp.exe" /uninstall' at the start of your uninstaller.
It might be possible to use one of the IToast* interfaces with the System plugin but there is a lot of code needed and I don't know if Windows let's you pretend to be another application by using its Application Model Id. For example, MSDN has this to say about IToastNotificationHistory::Remove:
The app ID of the app that sent the specified toast notification. This app must be part of the same app package as the app making this remove request.
MSDN also has this to say about desktop apps:
Generally, sending a toast notification from a desktop app is the same as sending it from a Windows Store app. However, you should be aware of these differences and requirements:
For a desktop app to display a toast, the app must have a shortcut on the Start screen.
The shortcut must have an AppUserModelID.
Desktop apps cannot schedule a toast.
Using following function to Sql Express using Nsis But getting error while running this function named InstallSQL the function is shown below
Function InstallSQL
File /oname=$TEMP\SQLEXPR32.exe Prerequisites\SQLEXPR32.exe
ExecWait '$TEMP\SQLEXPR32.exe /Q /ACTION=Install /IACCEPTSQLSERVERLICENSETERMS /ROLE=AllFeatures_WithDefaults /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /INSTANCENAME=STELLSQL /SecurityMode=SQL /SAPWD="neptune" /IndicateProgress'
FunctionEnd
below is the image of error
I know it's too late to answer, but it will be helpful who refer this page.
I have installed SQL Express 2014 SP1 with silent installation using nsis script which works successfully.
Function InstallSQL
ExecWait '"$temp\SQLEXPRADV_x64_ENU.EXE" /Q /ACTION=Install /SkipRules=RebootRequiredCheck /IACCEPTSQLSERVERLICENSETERMS /FEATURES=SQL,SSMS /INSTANCENAME="SQLEXPRESS2014" /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSVCStartupType=Automatic /AddCurrentUserAsSqlAdmin /ENABLERANU=1 /hideconsole /SECURITYMODE=SQL /SAPWD="Sql#1234" /AGTSVCSTARTUPTYPE=Manual /NPENABLED=1 /TCPENABLED=1'
FunctionEnd
Note: You can specify setup location instead of $temp
I have a nsi script which starts as following:
Name "myprog"
OutFile "myprog.exe"
InstallDir $PROGRAMFILES32\xx
InstallDirRegKey HKLM "Software\yy\xx" "InstallDir"
RequestExecutionLevel admin
AutoCloseWindow true
BrandingText /TRIMCENTER "me"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf"
Caption "Updateprogramm"
It works fine on my dev machine, but not on production (e.g. the user has only readonly permissions for the registry path). It is a Win 2003 server os. Even when the registry key exists, the program tries to install in $PROGRAMFILES32\xx.
InstallDirRegKey only needs read access.
The thing troubling thing for me is that you are talking about read only, but you have "RequestExecutionLevel admin" in your script. This says to me that you require admin rights and when you have "RequestExecutionLevel admin" you also need to use UserInfo::GetAccountType (To handle < NT6 systems and Vista+ when UAC is off)