Installing MS SQL Server Express 2017 with Inno Installer - inno-setup

I'm desperately trying to install SQL Server Express 2017 with Inno Installer.
Within my installer I include the extracted installer files.
That means that I already executed the common SQLEXPR_x64_ENU.exe, to avoid the "extract-temp-folder" prompt while my installer is running.
I execute the following on the cmd:
{somePath}\SQLEXPR_x64_ENU\setup.exe /ACTION=Install /Q /SKIPRULES=RebootRequiredCheck /SUPPRESSPRIVACYSTATEMENTNOTICE=1 /IAcceptSQLServerLicenseTerms=1 /SECURITYMODE=SQL /SAPWD=secretPW /ConfigurationFile=ConfigurationFileExpr.ini
The install succeeds.
But when I do the same within my InnoInstaller-File like this:
...
[Files]
Source: "SQLEXPR_x64_ENU\*"; DestDir: "{tmp}\SQLEXPR_x64_ENU"; Check: not SQLExpress_Check; Flags: recursesubdirs;
[Run]
Filename: "{tmp}\SQLEXPR_x64_ENU\setup.exe"; Description: "Installing SQL Server Express 2017..."; StatusMsg: "Installing SQL Server Express 2017..."; \
Parameters: "/ACTION=Install /Q /SKIPRULES=RebootRequiredCheck /SUPPRESSPRIVACYSTATEMENTNOTICE=1 /IAcceptSQLServerLicenseTerms=1 /SECURITYMODE=SQL /SAPWD=secretPW /ConfigurationFile=ConfigurationFileExpr.ini"; Check: not SQLExpress_Check; Flags: runascurrentuser;
...
SQL Installer fails with the following error:
Exception type: System.MissingMethodException
Message:
Method not found: 'Void Microsoft.SqlServer.Chainer.Infrastructure.RoleService.Initialize(Microsoft.SQL.Chainer.Product.RolesType)'.
HResult : 0x80131513
Data:
DisableWatson = true
Stack:
at Microsoft.SqlServer.Configuration.BootstrapExtension.InitializeRoleServiceAction.ExecuteAction(String actionId)
at Microsoft.SqlServer.Chainer.Infrastructure.Action.Execute(String actionId, TextWriter errorStream)
at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.<>c__DisplayClasse.<ExecuteActionWithRetryHelper>b__b()
at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.ExecuteActionHelper(ActionWorker workerDelegate)
Is this a permission error?
I do not have a clue.
On cmd-shell it works, but not on InnoInstaller.
Thanks in advance for your efforts and have a nice day.

Solution for me was provided by Gavin Lambert on the Inno Setup Forum :
If you're [installing from the directory of unpacked files], you need to use {sd}\shortname as the DestDir (usually combined with deleteafterinstall) -- you can't put the files in {tmp} or any similar path as the files are very deeply nested and the db installer ends up failing to access some files because the path is too long.

If you use an unpacked installer file, here is what should work absolutely perfect.
SQLEXPR_x64_ENU.exe /x:%temp%\SQLEXPR_x64_ENU\ /QS /ACTION=Install /SKIPRULES=RebootRequiredCheck /SUPPRESSPRIVACYSTATEMENTNOTICE=1 /IAcceptSQLServerLicenseTerms=1 /SECURITYMODE=SQL /SAPWD=secretPW /ConfigurationFile=ConfigurationFileExpr.ini
In the above command, /x:%temp%\SQLEXPR_x64_ENU\ is the very important switch where it describes the extraction location and with combination to /QS it will show you the progress on screen but will not ask for any input.
You may have to change %temp% to appropriate command to grab a windows temporary folder in your installer. The command I have posted is good for command-line execution.
Enjoy! :)

Related

Launching App from Inno Setup so that setup process closes

What is the procedure to run/launch an application after a silent setup, so that the Setup installer closes and returns the exit code?
I need this behavior for launcher scripts to detect if setup passed/failed, while the end-user may start to use the app already.
Use nowait flag:
[Run]
Filename: "{app}\check.exe"; Flags: nowait

Elegantly using try / catch with dotnet constants in Inno [Run] section [duplicate]

I have a .NET DLL. It can be registered by RegAsm .NET 3.5 and .NET 4.5.
I use this codes in my setup script:
[Run]
Filename: "{dotnet40}\RegAsm.exe"; Parameters: "my.dll"; WorkingDir: "{app}"; Flags: skipifdoesntexist; StatusMsg: "Registering Controls."
Filename: "{dotnet4064}\RegAsm.exe"; Parameters: "my.dll"; WorkingDir: "{app}"; Flags: skipifdoesntexist; StatusMsg: "Registering Controls."
Filename: "{dotnet20}\RegAsm.exe"; Parameters: "my.dll"; WorkingDir: "{app}"; Flags: skipifdoesntexist; StatusMsg: "Registering Controls."
Filename: "{dotnet2064}\RegAsm.exe"; Parameters: "my.dll"; WorkingDir: "{app}"; Flags: skipifdoesntexist; StatusMsg: "Registering Controls."
It works well if .NET 3.5 and .NET 4.5 is installed on the target machine
I have a function in my script to checking .net in InitializeSetup. So I know one of these versions are installed on the system: v3.5 v4 v4.5
But
we get error in some cases like this: if we have not .NET 3.5 on the target machine
I guess the error reason is:
{dotnet20}
.NET Framework version 2.0 root directory. {dotnet20} is equivalent to {dotnet2032} unless the install is running in 64-bit
mode, in which case it is equivalent to {dotnet2064}.
An exception will be raised if an attempt is made to expand this constant on a system with no .NET Framework version 2.0 present.
My question is how can I handle and ignore this exception and prevent setup rollback:
Internal error: .Net Framework version 2.0 not found.
If you want to stick to the [Run] section and do not write this in a scripting code, then I think you don't have many options to choose from. An exception is raised whenever a constant cannot be expanded, and that is just this case. The only option I can think of is adding a Check function that will attempt to expand the constant in a protected try..except block and prevent the entry to be processed when an exception is raised. Something like follows (based on your code, shortened):
[Run]
Filename: "{dotnet20}\RegAsm.exe"; Parameters: "File.dll"; Check: RegAsmDotNet20Exists
[Code]
function RegAsmDotNet20Exists: Boolean;
begin
try
// process the entry only if the target binary could be found (and so the
// folder constant could have been properly expanded)
Result := FileExists(ExpandConstant('{dotnet20}\RegAsm.exe'));
except
// this is the fallback in case the folder constant could not be expanded,
// or something unexpected happened when checking if the binary file to be
// executed exists; in such case, don't process the entry
Result := False;
end;
end;
Another, quite cleaner and a bit safer option would be doing your assembly registration purely from [Code] section in some of the postinstall events. Even though you'd still need to catch exceptions when using those constants, you would get more control over that tool (e.g. you could get the exit code to obtain an error reason if that tool uses it).

Inno Setup desktop shortcut (link) which has "Run as administrator" advanced property set

I am struggling to get Inno setup (5.5.9u) to created a desktop shortcut that has an icon and has the advanced property of "Run as administrator" set.
Issue
This question, is a little different than: How to set 'Run as administrator' on a file using Inno Setup
Since what I am trying to do is not run a program at setup time with admin rights, (setup is already running at Admin), but rather leave a link on the desktop that has has the advanced property of "Run as Administrator".
Code Sample
[Icons]
Name: "{group}\EGPL Watson Uninstall"; Filename: "{uninstallexe}"; \
WorkingDir: "{app}"
Name: "{commondesktop}\DashBoard"; \
Filename: "{app}\dashboard\node_modules\electron\dist\electron.exe main.js"; \
WorkingDir: "{app}\dashboard"; \
IconFilename: "{src}\dashboard\build\configure.ico"
First, make sure you have a very good reason to run your application with Administrator privileges. User applications should not need Administrator privileges. If they need it, it's usually a sign of a bad design. One common (bad) reason to want an application to run with Administrator privileges, is that the application needs to write to its installation folder.
See Application does not work when installed with Inno Setup
Inno Setup does not natively support creating a shortcut with "Run as Administrator" flag set.
The "Run as Administrator" flag is a bit the .lnk file. See:
LinkFlags in [MS-SHLLINK]: Shell Link (.LNK) Binary File Format;
How to create a Run As Administrator shortcut using Powershell
How can I use JScript to create a shortcut that uses "Run as Administrator"
You can set the bit using the following code:
[Icons]
Name: "{userdesktop}\My Program"; Filename: "{app}\MyProg.exe"; \
AfterInstall: SetElevationBit('{userdesktop}\My Program.lnk')
[Code]
procedure SetElevationBit(Filename: string);
var
Buffer: string;
Stream: TStream;
begin
Filename := ExpandConstant(Filename);
Log('Setting elevation bit for ' + Filename);
Stream := TFileStream.Create(FileName, fmOpenReadWrite);
try
Stream.Seek(21, soFromBeginning);
SetLength(Buffer, 1);
Stream.ReadBuffer(Buffer, 1);
Buffer[1] := Chr(Ord(Buffer[1]) or $20);
Stream.Seek(-1, soFromCurrent);
Stream.WriteBuffer(Buffer, 1);
finally
Stream.Free;
end;
end;
Tested on Unicode version of Inno Setup (the only version as of Inno Setup 6). But it should, even more naturally, work on Ansi version too.

Inno Setup "Wrong Parameter" (Wusa.exe and .msu)

I am trying to create a Setup using Inno Setup. Because I have to install a .msu file, I use the Wusa.exe.
The important code line:
Filename: {sys}\wusa.exe; WorkingDir: {app}; Parameters: {app}\Windows6.1-KB2506143-x64.msu;
Every time I launch the program, it gives me this error and I couldn't figure out a solution yet:
2147942487 "Wrong Parameter."(Commandline:""C:\Windows\system32\wusa.exe" C:\Program Files (x86)\Phone-O-Mat\Windows6.1-KB2506143-x64.msu")
You are missing quotes around the file name. You need these, as the {app} resolves to a path with spaces:
Filename: {sys}\wusa.exe; WorkingDir: {app}; \
Parameters: """{app}\Windows6.1-KB2506143-x64.msu"""

Inno Setup is not including any of indicated files in destination folder

This is the first time I've used an installer program other than Access Developer Extensions. I have couple of MS Access files I'm trying to have installed into the user's AppData\Local folder. The only thing it will seem to do is put two files in that folder: unins000.exe and unins000.dat. It seems to ignore the files I want put in there, although when I compile it's definitely including them in the Setup.exe file. Here is the script - can someone tell me what could be wrong here? It doesn't seem to matter if the destination folder or files exist or not - I get the same result.
; -- LEAP.iss --
[Setup]
AppName=LEAP
AppVersion=1.1
DefaultDirName={localappdata}\LEAP
DefaultGroupName=LEAP
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Output
[Files]
Source: "China.accdb"; DestDir: "{localappdata}"; DestName: "China.accdr"
Source: "Replica of China_be.mdb"; DestDir: "{localappdata}"
[Icons]
Name: "{group}\LEAP"; Filename: "{localappdata}\China.accdr"
Name: "{userdesktop}\LEAP"; Filename: "{localappdata}\China.accdr"
You want to replace {localappdata} with {app} in the [Files] and [Icons] sections. The {app} constant is defined once the user selects the install location on the "Select Destination Location" wizard page. Your end-users might not appreciate that you've allow them to choose a location to install your program, only to find out that you've actually hard-coded that location in the installer.
If you don't want them to choose a location, then set DisableDirPage=true in [Setup].
You should also establish an AppID value in [Setup].

Resources