How to use RequestExecutionLevel inside IF THEN block - nsis

I have nsis package that consist of 3 items:
1. .Net 4.0 setup
2. C++ redistr
3. My App
My installer is always silent. In this package I check installed version of .Net and C++ and install from my package if I have bigger, but if user have correct version of net and c++, my package just export my app to temp folder and run it.
To install .net or c++ user must has admin rigths, but to run my app it is not needed. I don`t want always request admin rigths with RequestExecutionLevel admin
It is possible some how implement such logic in package:
IF (user_has_net != true || user_has_c++ != true) {
RequestExecutionLevel admin
} else {
RequestExecutionLevel user
}

The RequestExecutionLevel property is set for your installer at compile time and is embedded in the installers manifest. It can't be set at runtime.
The best workaround I can think of in your case would be to embed another installer that handles the C++ runtime libraries and .Net. Then that installer can have RequestExecutionLevel set to admin and be extracted and executed by your primary installer as needed.
Something like this should work.
IF (user_has_net != true || user_has_c++ != true) {
SetOutPath "$TEMP"
File "OtherInstaller.exe"
ExecWait "$TEMP\OtherInstaller.exe"
}

Related

Electronjs - Delete registry entries when uninstalled

I need to delete Windows registry entries created by the application when the application is uninstalled.
The application is packed with electron-builder and i need to delete registry entries whether it is installed with .exe the with the windows store (appx)
What's the best way to accomplish this?
You can try to read this documentation https://www.electron.build/configuration/nsis.html.I am building an application with electron-builder too but I had not yet asked myself this problem. Thank you :)
" deleteAppDataOnUninstall = false Boolean - one-click installer only. Whether to delete app data on uninstall. "
you can add a custom nsis script in electron build. Use include option
https://www.electron.build/configuration/nsis.html#custom-nsis-script
then you can add below macro in the script file
!macro customUnInstall
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run"
"SomeLeafLevelEntry"
DeleteRegKey HKLM "SOFTWARE\XYZApp\AppTopLevelKey"
!macroend
that should delete the registry values
More info : https://nsis.sourceforge.io/Registry_plug-in#Delete_Registry_Key_.28same_as_DeleteRegKey.29
https://nsis-dev.github.io/NSIS-Forums/html/t-197518.html

NSIS: Writing to registry (not HKLM)

Please help me: I want to write some data to registry. You might say "Wait, wait, this is one of the basic features in NSIS!", but, I want to write to the app registry (HKCU, not HKLM). The main purpose is: when the installer installs my product it also installs my update manager. I just want to write the product installation directory to the Updater branch, so it can further fetch the update package and install it to the product directory.
If you have RequestExecutionLevel admin in your script and you are installing to $ProgramFiles then you are doing a machine/all users install and the installer should not write to HKCU. Your application must initialize its entries in HKCU and AppData the first time the user runs it. You cannot do it in the installer because UAC might run the installer as the "wrong" user.
If you have RequestExecutionLevel user in your script then you are doing a single user install and the installer should only write to HKCU and [Local]AppData.

Copy chrome extension with NSIS to install directory

I wanted to install chrome extension to chrome using NSIS. First, i want to copy the extension to installation directory and i wrote the following on the NSIS script
Section "sampleext" SecDummy
SetOutPath "$INSTDIR"
; ADD YOUR OWN FILES HERE...
File "Script.nsi"
File "sampleext.crx"
; Store installation folder
WriteRegStr HKCU "Software\sampleext" "" $INSTDIR
; Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
But, i get the following error when building it.
Error Error in script "sampleext.crx" on line 1 : Invalid command:
Cr24 sampleext
how can i solve this?
I don't think you can install the .crx file anymore.
Warning: As of Chrome 33, Windows users can only download extensions hosted in the Chrome Web store, except for installs via enterprise policy or developer mode (see Protecting Windows users from malicious extensions). As of Chrome 44, no external installs are allowed from a path to a local .crx on Mac (see Continuing to protect Chrome users from malicious extensions).
Instead, you are supposed to create a registry key as follows:
Find or create the following key in the registry:
32-bit Windows: HKEY_LOCAL_MACHINE\Software\Google\Chrome\Extensions
64-bit Windows: HKEY_LOCAL_MACHINE\Software\Wow6432Node\Google\Chrome\Extensions
Create a new key under the Extensions key with the same name as the ID of your extension.
In your extension key, create a property, "update_url", and set it to the value: https://clients2.google.com/service/update2/crx (this points to your extension's crx in the Chrome Web Store)
See the Alternative Extension Distribution Options for details.

how to check software installed in NSIS?

i have created an installer using NSIS to install a software say googletalk in my system using following NSIS script ,
Name "installer"
OutFile "new_setup.exe"
InstallDir "$PROGRAMFILES\Google talk"
Section
SetOutPath $INSTDIR
execWait '$DESKTOP\googletalk-setup.exe'
SectionEnd
Now if i execute the installer once again, before installing it should check whether that software already exists or not.
So in NSIS how to achieve it ?.
Please tell me with code.
Thanks in advance!.
During installation, you need to create informations for uninstall in registry. (visible in Add/remove program on Windows control panel)
I advice you to follow this example :
http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs
Then on your ".onInit" function, you just have to check these values with a ReadRegStr :
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.12
Hope this can help you.

Prevent additional uninstaller uninstall everything

I have an innosetup installer which installs a plugin into the root directory of an application which is also installed with innosetup. After installing my plugin into this dir there are multiple uninst* files:
app/
unins000.exe (the apps uninstaller)
unins000.dat
unins001.exe (another plugin's uninstaller)
unins001.dat
unins002.exe (my plugin's uninstaller)
unins002.dat
Problem is running unins002.exe uninstalls all files in this folder, I need only the files created by my plugin to be uninstalled.
How can I achieve this?
In the [setup] section you need to provide a different (or non-default) AppId value.
When the installer runs and the same the AppId exists for an existing uninstall manifest then Inno will merge them.
Fixed. It was due to a misconfigured UninstallDelete section.

Resources