Nsis 3 supports new commands like Unicode true. I want a script that works with makensis2 and makensis3. Is this possible? I use linux.
I tried to write a script. But the compiler doens't accept this
Update:
!if "${NSIS_PACKEDVERSION}" > 0x02ffffff ; NSIS 3+
Unicode true
ManifestSupportedOS all
!else
!warning "NSIS v2, compiling ANSI installer!"
!endif
I use this but get still the error message warning 7070: Invalid number: "${NSIS_PACKEDVERSION}".
${If} is a run-time command but you need to use preprocessor instructions and all of those start with !.
!if "${NSIS_PACKEDVERSION}" > 0x02ffffff ; NSIS 3+
Unicode true
!else
!warning "NSIS v2, compiling ANSI installer!"
!endif
This is the official way but might not work with unofficial releases if VER_PACKED was not passed to SCons when building MakeNSIS.
Here is something that relies on the improved number parser in NSIS v3 instead:
!if 0n1 > 0 ; >= 3.0b0 (Documented in chapter 5.1)
Unicode true
!else
!warning "NSIS v2, compiling ANSI installer!"
!endif
Related
I'd like to use the ShellExecAsUser plugin with NSIS 3.08.
I have placed the plugin .dll Unicode version into the "Plugins\x86-unicode" and the ANSI version into the "Plugins\x86-ansi" directory.
When I do
!insertmacro ShellExecAsUser::ShellExecAsUser 'open' '$INSTDIR\bin\program.exe' '' '' ''
... then makensis produces the following error:
!insertmacro: macro named "ShellExecAsUser::ShellExecAsUser" not
found!
What do I need to do to make the plugin work?
Plug-ins don't use !insertmacro.
Just call it directly:
ShellExecAsUser::ShellExecAsUser "" cmd.exe "/k echo Hello" SW_SHOWDEFAULT
I want to create a Suite installer for the various application we develop. The structure is as follows:
Application A
Requires no driver installation
Application B
Requires driver 1 and 2
Application C
Requires driver 2 and 3
The user has the option to install any application he wants, or multiple. I know how to use Sections for this. This will work fine if the user selects only Application A, or Application A with either B or C. However, if the user selects Application B and C, I would like to avoid that driver 2 will be prompted to install twice.
Is there a way to achieve this? For instance, is it possible to know when the section for Application C is executed, that the section for Application B has already been executed, and that driver 2 does not need to be installed again?
There are probably many ways to handle this, one is to put the driver in a hidden section that you make sure is in the correct state:
!include LogicLib.nsh
!include Sections.nsh
!include x64.nsh
Page Components
Page Directory
Page InstFiles
Section "-Driver2" SID_DRIVER2
${If} ${IsNativeAMD64}
; Install AMD64 64-bit driver/library
${ElseIf} ${IsNativeARM64}
; Install ARM64 64-bit driver/library
${ElseIf} ${IsNativeIA32}
; Install i386 32-bit driver/library
${Else}
Abort "Unsupported CPU architecture!"
${EndIf}
SectionEnd
Section "App B" SID_APPB
SectionEnd
Section /o "App C" SID_APPC
SectionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${SID_APPB}
${OrIf} ${SectionIsSelected} ${SID_APPC}
!insertmacro SelectSection ${SID_DRIVER2}
${Else}
!insertmacro UnselectSection ${SID_DRIVER2}
${EndIf}
FunctionEnd
Function .onInit
Call .onSelChange ; Make sure things are configured correctly in silent installers
FunctionEnd
I have created my windows application installer using NSIS 3.02.1.
In language selection textbox, language is display 2 times.
EX.
English/English
Chinese (Simplified) / Hanyu (Jiantizi)
Russian / Russkij...
In my previous setup, which was build using NSIS 2.46 this language setup is looks like :
English
Chinese
Russian...
I don't want to change this in my language selection setup. How can I achieve language selection setup as define in NSIS 2.46 in NSIS 3.02.1?
If you still support Windows 95/98/ME then I would recommend that you use NSIS v2.51, it has all the security updates from NSIS v3 and better language support in the language selection dialog.
If you only support newer versions of Windows then you should add Unicode True to your script, this will display the native name of the language in the language selection dialog and all languages are supported on all systems.
If you insist on creating ANSI installers with NSIS v3 then you can use the undocumented LANGFILE_LANGDLL_FMT define:
OutFile test.exe
RequestExecutionLevel user
!define LANGFILE_LANGDLL_FMT "%NATIVEASCIINAME%" ; %NATIVENAME% can also be used but it will display ? in some cases.
!include "MUI2.nsh"
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "SimpChinese"
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Section
SectionEnd
when I was looking for an answer to how to find out if a Windows OS was 32bit or 64bit, I stumbled upon this other answer: Use NSIS to install 32bit... and used this code below.
!include x64.nsh
Function .onInit
#Determine the bitness of the OS and enable the correct section
${If} ${RunningX64}
SectionSetFlags ${SEC0000} ${SECTION_OFF}
SectionSetFlags ${SEC0001} ${SF_SELECTED}
${Else}
SectionSetFlags ${SEC0001} ${SECTION_OFF}
SectionSetFlags ${SEC0000} ${SF_SELECTED}
${EndIf}
FunctionEnd
However, I run into this error:
!insertmacro: If
!insertmacro: macro named "_LOGICLIB_TEMP" not found!
Error in macro _RunningX64 on macroline 1
Error in macro If on macroline 5
I'm not sure what that's all about. I figured it might have been something to do with LogicLib.nsh, but I am using the exact same if, else statements else where in the same script and no issues there. So, it leads me to believe that its the x64.nsh library that is stopping me.
I have never seen this error before. Your current code should work unless you happen to define LOGICLIB somewhere in your code before you include x64.nsh and/or LogicLib.nsh.
Try putting this at the top of your .nsi:
!ifdef LOGICLIB
!warning "LOGICLIB should not be defined here"
!undef LOGICLIB
!endif
!include LogicLib.nsh
!ifmacrondef _LOGICLIB_TEMP
!error "Corrupted LogicLib.nsh?"
!endif
!include x64.nsh
I want to install VC++ Redist 2008 in my NSIS setup script. I got the following piece of script to do it:
; Test if Visual Studio Redistributables 2005+ SP1 installed
; Returns -1 if there is no VC redistributables intstalled
Function CheckVCRedist
Push $R0
ClearErrors
ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7299052b-02a4-4627-81f2-1818da5d550d}" "Version"
; if VS 2005+ redist SP1 not installed, install it
IfErrors 0 VSRedistInstalled
StrCpy $R0 "-1"
VSRedistInstalled:
Exch $R0
FunctionEnd
Basically its for VC++ Redist 2005, but i've edited the reg settings to check for presence of 2008(is it ok to do so?). I need the piece of script/command to install the VC++ Redist 2008.
where do i store the VC setup and how to execute in silent mode.
Is it ok to check at .onInit?
Could someone please give a complete script which checks for presence and how to execute it in silent mode.
Thanks,
Well I am not much sure about how to check for if vcredist is already installed from registry.
What I do for my installer is, to check for a particular dll file in the system which the vcredist installs (and for which I am installing vcredist). So if that file is present in my $WinDir I assume vcredist is already installed otherwise I download & install(silently) the vcredist.
Following is my script which may be of some help to you:
ifFileExists $Windir\System32\mfc100.dll +2 0
StrCpy $IsMfcInstalled "no"
${If} $IsMfcInstalled == "no"
download1:
NSISdl::download "http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe" "$Temp/vcredist_x86.exe"
pop $0
StrCmp "$0" "success" execStep1 instAbort1
execStep1:
Execwait '"$Temp/vcredist_x86.exe" /q' ; '/q' to install silently
pop $0
StrCmp "$0" "success" done execStep1
instAbort1:
StrCmp $0 "cancel" 0 +1
MessageBox MB_OKCANCEL "Connection Timed Out. Retry ? " IDOK download1 IDCANCEL 0
Quit
${else}
goto done
${endIf}
done: