How to copy and install a dll into assembly folder using NSIS on an Windows OS with elevated UAC - nsis

I am building an application setup where the installation involves copying and registering Microsoft.VisualBasic.PowerPacks.Vs into the Windows assembly folder. This process sometimes fails on a Windows 7 system where the UAC is active.Currently, i use the following script in a section:
SetOutPath $INSTDIR\bin
File "..\MyFolder\systemfiles\Microsoft.VisualBasic.PowerPacks.Vs.dll
ExecWait '"$R0\RegAsm.exe" Microsoft.VisualBasic.PowerPacks.Vs.dll'
Requesting to kindly provide me some script/solution to successfully copy and register the dll even when the UAC is elevated on a Windows 7 system

All NSIS installers should contain a RequestExecutionLevel attribute, it is inspected by Windows Vista and later when UAC is on.
Your installer needs to request administrator privileges when you are installing things in GAC, SxS etc:
Outfile RequireAdmin.exe
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
!include LogicLib.nsh
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
Page InstFile
Section
SectionEnd

Related

Launch wrapped exe with NSIS installer on windows startup

I am creating an installer that is wrapping an abc.exe with it. This installer is running the exe as a tray icon. But when I restart my system this exe will stop and won't be seen in tray icon anymore. I want this exe to be started again on windows restart. How can this be achieved?
I have tried below commands but not helpful:
CreateShortCut "$SMPROGRAMS${abc}.lnk" "$INSTDIR\abc.exe"
CreateDirectory "$SMPROGRAMS\abc"
CreateShortCut "$SMPROGRAMS\abc\abc.lnk" "$INSTDIR\abc.exe"
CreateShortCut "$DESKTOP\abc.lnk" "$INSTDIR\abc.exe"
CreateShortCut "$SMPROGRAMS\abc\Uninstall abc.lnk" "$INSTDIR\uninstall.exe"
Any help is appreciated!!!Thanks in advance
Windows does not know that the application is always supposed to run, you need to register it in the correct location.
CreateShortcut "$SMSTARTUP\MyApp.lnk" "$INSTDIR\abc.exe"

Can not Access Database in ProgramData Folder

I'm working on a project with a SQLite database. It works fine in my Visual Studio project. When I try to deploy using Inno Setup the MyApp.exe cannot write (Read Only) the database file in the folder ProgramData.
If I run the setup by Right-Click > Run as Administrator the MyApp.exe is then capable of writing the database file.
So I added the admin permission using PrivilegesRequired=admin But it still doesn’t work.
I can't figure-out:
Why MyApp.exe cannot write a file in ProgramData except running the setup as Admin?
Why this PrivilegesRequired=admin code doesn't work?
My Operating System is Windows 10 and I'm logged in as the admin. My Inno Setup compiler version is 5.6.1.
[Setup]
PrivilegesRequired=admin
[Files]
Source: "{#SourceFolder}MyApp.exe"; DestDir: "{app}"
Source: "{#SourceFolder}Database.db"; DestDir: "{commonappdata}\MyApp"; Flags: ignoreversion
I can give to MyApp.exe to admin permission in C# code, but still need to work this app in a non-admin account

Install DotNet Framework 2.0 and Vc++Redist 2008 using NSIS

I have an application setup made using NSIS. The application needs DotNet 2.0 and VC++Redist 2008 to run. Currently i am installing these dependencies separately.I need a way to install DotNet Framework and Vc++Redist 2008 from within my NSIS Scirpt if not present on the system(if present installer should skip the dependencies). Need some piece of script and a step by step procedure to do this. Kindly help.
Thanks,
You should try the search engine before asking a question that was already asked, here and on the NSIS wiki:
how to detect if CV redist is installed (for VC2005)
how to detect VC2008 redist (to get the specific vc2008 class id)
Also:
How to perform a silent install of the Visual C++ 2008 redistributable packages.
Basically you need something like
ExecWait '$TEMP\vcredist_x86_SP1.exe /Q' $0
DetailPrint "-- vcredist_x86_SP1.exe runtime exit code = '$0'"
How to check for an installed version of dotnet
Embedding other installers with exemples for dotnet, and other third party components

Silent install parameter ignored, InstallShield 2009

I've just inherited an InstallShield 2009 project from a guy who left (oh joy) and am trying to get the setup.exe to run in silent mode. The project is a Basic MSI project and according to the documentation, I should be able to specify the /s switch combined with /v/qn to make the installer and MSI process silent. However, when I do this, the process shows all the dialogs as normal. I've tried generating an answer file with the /r switch, but this fails to produce any sign of a setup.iss any where (I checked the windows folder, which is where it apparently goes).
Why would the process be ignoring the silent commands? I can see nothing in the install log that indicates a problem... The command line I am using is this:
setup.exe /s /v/qn
I've tried various combinations of lower and uppercase to no avail. Any advice would be appreciated.
Steve
Edit:
I've also tried:
setup.exe /s /v"/qn"
Which did not work also.
Edit 2:
It might be worth pointing out that the installer is performing and upgrade from a previous version of the product to a newer version. The first dialog that pops up is the "extracting msi" dialog followed by the "welcome to upgrade" dialog.
The following should work for InstallShield 9:
Setup.exe /s /V/qn
If you want to send commands to the MSI, do the following:
Setup.exe /s /V"/qn ADDLOCAL=ALL"
NOTE: The v is capitalized. Some versions of InstallShield use lowercase and others use Uppercase for v.
Try
setup.exe /s /v"/qn"
Basically /s is to tell setup.exe to run silent and /v is to pass parms to MSI so you have to wrap it in quotes. /qn tells MSI to run with no UI.
Setup.exe and Update.exe Command-Line Parameters
The Command-Line Options for the Microsoft Windows Installer Tool Msiexec.exe

nsis: How do I create a start menu shortcut to open a folder?

My NSIS installer creates Start Menu links to run and uninstall my application.
Using NSIS, how do I create StartMenu shortcut to open a folder in Windows Explorer?
the same as any other shortcut
CreateShortcut "$smprograms\my app\my shortcut.lnk" "c:\path\to\folder"
this is explorer 99% of the time, and its really what you want, but if you want to force explorer
CreateShortcut "$smprograms\my app\my shortcut.lnk" "$windir\explorer.exe" '/e,"c:\path\to\folder"'
but that shortcut will have the wrong icon etc

Resources