Why doesn't Inno Setup uninstall my SQL Server 2017 named instance? - sql-server

I have an Inno Setup v5.5.9 file shown below;
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Files]
Source: "Setups\SQLEXPR_x64_ENU.exe"; DestDir: {tmp}\Setups; Flags: nocompression;
[UninstallRun]
Filename: {tmp}\Setups\SQLEXPR_x64_ENU.exe; Parameters: "/QS /ACTION=unInstall /FEATURES=SQLENGINE /INSTANCENAME=CASSQL";
[Run]
Filename: {tmp}\Setups\SQLEXPR_x64_ENU.exe; Parameters: "/QS /ACTION=Install /FEATURES=SQLENGINE /INSTANCENAME=CASSQL /INSTANCEDIR=""{pf}\Microsoft SQL Server\MSSQL14.CASSQL"" /SQLSVCACCOUNT=""NT Authority\Network Service"" /TCPENABLED=1 /SECURITYMODE=SQL /ADDCURRENTUSERASSQLADMIN /SAPWD=sapassword /IACCEPTSQLSERVERLICENSETERMS";
The install works just fine, but once installed, if I go to Control Panel and right-click on the installer and select Uninstall, the uninstall will remove the installer from control panel but it doesn't actually run the SQLEXPR_x64_ENU.exe or uninstall the SQL Server Express named instance.
I read that Inno Setup would automatically handle uninstall, so I removed the [UninstallRun] section, but had the same result.
I can run the following :
SQLEXPR_x64_ENU.exe /QS /ACTION=unInstall /FEATURES=SQLENGINE
/INSTANCENAME=CASSQL
From the command line and it works as expected.
[UPDATE #1 7/23/19]
I added SetupLogging=yes to the [Setup] section, hoping to see something useful in a log file. Inno Setup created the log file when I ran the install, but did not create any log file when I ran the Uninstall by right-clicking on the Inno Setup generated installer in Control Panel.
What am I missing here?

The files installed to {tmp} exist only for a duration of the installation:
Temporary directory used by Setup or Uninstall. This is not the value of the user's TEMP environment variable. It is a subdirectory of the user's temporary directory which is created by Setup or Uninstall at startup (with a name like "C:\WINDOWS\TEMP\IS-xxxxx.tmp"). All files and subdirectories in this directory are deleted when Setup or Uninstall exits. During Setup, this is primarily useful for extracting files that are to be executed in the [Run] section but aren't needed after the installation.
So at the time you run the uninstaller, the {tmp}\Setups\SQLEXPR_x64_ENU.exe does not exist anymore.
If you run the uninstaller manually from command-line and add /log=C:\some\path\uninstall.log switch, you wil find something like this in the log:
2019-07-24 08:46:04.614 Running Exec filename: C:\Users\marti\AppData\Local\Temp\is-K316U.tmp\Setups\SQLEXPR_x64_ENU.exe
2019-07-24 08:46:04.614 Running Exec parameters: /QS /ACTION=unInstall /FEATURES=SQLENGINE /INSTANCENAME=CASSQL
2019-07-24 08:46:04.615 CreateProcess failed (2).
If you want to be able to run SQLEXPR_x64_ENU.exe during uninstallation, you have to deploy it to a different folder, like to {app}.
You can can also embed the file into the uninstaller itself, if it is not too large (what it possibly is):
How keep uninstall files inside uninstaller?

Related

Install SQL Server LocalDB on Server Core 2019 in Docker container

Within a Docker container (image = mcr.microsoft.com/windows/servercore:ltsc2019), I have downloaded the SQL Server Express 2019 installer.
I have successfully downloaded the LocalDB msi with:
SQL2019-SSEI-Expr.exe /Action=Download /MediaType=LocalDB /Quiet
The file is downloaded to:
C:\Users\ContainerAdministrator\Downloads\en-us\SqlLocalDB.msi
However... running msiexec fails without any error messages. After navigating to the path mentioned above, I execute:
msiexec.exe /qb /i .\SqlLocalDB.msi IAcceptSqlLocalDBLicenseTerms=YES
The command immediately drops back to the command line after zero delay. Nothing ever gets installed.
What am I missing?
Edit:
I'm trying to use LocalDB because this will eventually be an Azure Pipelines build agent. We use Redgate's "SqlChangeAutomation" powershell tools which uses LocalDB.
Edit 2:
Not sure if this is progress yet, however... I mucked around with msiexec logging for a bit and discovered I could run it with the /a flag instead of /i and get it to successfully install.
msiexec.exe /qn /a SqlLocalDB.msi IAcceptSqlServerLicenseTerms=YES /L*V "C:\installers\SQL\install.log"
Unfortunately, however, upon navigating to C:\Program Files\Microsoft SQL Server\150\tools\binn and running SqlLocalDB.exe info, I get this:
Call to LocalDBFormatMessage failed. Error code returned:
2311389462.
Error in LocalDBFormatMessage! Error code returned:
2311389462.
SQL LocalDB requires the Visual C++ redistributables, else many things won't go right (my problem was that SqlWriter service wouldn't create during install at all).
EDIT: it seems that I can use chocolatey to install the vc_redist and a older version of localdb. (Filing ticket to ask for the sqllocaldb package to be updated to 2019) so that would simplify things for most people. Keeping raw arguments/commands below just in case though.
My powershell steps for exact arguments (assuming you collect required files):
start-process .\VC_redist.x64.exe -Wait -ArgumentList #('/install','/norestart','/passive') Note I am using the redist from https://aka.ms/vs/16/release/vc_redist.x64.exe which should be the 2019, but spattering of comments say I should have used either the one in the SQL installer package, or some 2015 version. However neither of those "worked" for me in the containers, but that could have been me invoking them wrong. Besides which, further packages I need to install want 2019 anyways.
start-process msiexec -Wait -ArgumentList #('/i','SqlLocalDB.msi','/qn','/norestart','/L*V','install.log','IACCEPTSQLLOCALDBLICENSETE RMS=YES') Note that "/i" instead of "/a" worked correctly at this point, and the "/norestart" option. This was found from the choco localdb command source.
Useful powershell snippet to get some event logs (change "System" for "Application" for others) that helped me puzzle things out since no event-viewer in container: get-eventlog -LogName System -After (Get-Date).AddMinutes(-5) | ? {-not $_.Source.Contains("DCOM") } |?{-not $_.Message.Contains("depends on the Background Tasks Infrastructure Service")}| Format-List This and inspecting the "install.log" line-by-line from the SqlLocalDB.msi were what eventually led me on the right track.
I was trying to create images for pipelines too, installing via chocolatey, so I simply installed the chocolatey package for the redistributable too and that resolved the issue:
choco install vcredist-all -y
choco install sqllocaldb -y

Failed to install WPF in client PC - 0x80073CFD

I have an internal WPF application to be installed in client's PC.
Usually I start with the installation of these three dependency files
Microsoft.NET.CoreFramework.Debug.2.2.appx
Microsoft.NET.CoreRuntime.2.2.appx
Microsoft.VCLibs.x64.Debug.14.00.appx
Then, I need to install the appxbundle file to complete the installation.
But this client's PC don't have app installer and I was told to run PowerShell as administrator for installation. The command I used was
Add-AppxPackage -Path "file location/file"
I managed to install the dependency files but I couldn't install the appxbundle file.
The error appeared was as below
Deployment failed with HRESULT: 0x80073CFD, A Prerequisite for an
install could not be satisfied
How should I go about solving this error? For it only happens when the installation is done using PowerShell.

PowerShell v5.1 - Loading SqlServer Module does not load Read-SqlTableData or Write-SqlTableData, but Loads All Other Commands

On my Windows Server 2012 R2 server, the same server as my SQL Server service instance is running, I had upgraded to PowerShell v5.1. I proceeded to load the SqlServer module v21.1.18121. All commands loaded fine except for Read-SqlTableData and Write-SqlTableData. The darndest thing! When I load the same SqlServer module on my Win10 development box, all commands are present. I suspect something like a version problem with the available .Net framework or some such, or a collision with SQL Server's modules. Anyone with thoughts on this one?
The SqlServer module comes with the SQL Server installation and thems to be in a different version.
Module location on a SQL Server
(Get-Module -l SqlServer).path
-> C:\Program Files\WindowsPowerShell\Modules\SqlServer\SqlServer.psd1
Module location from PowerSehll gallery
(Get-Module -l SqlServer).path
-> C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.0.17279\SqlServer.psd1
You can enforce PowerSell to load a module from specific location
Install-Module -Name SqlServer
Import-Module -Name (Get-Module -l SqlServer).path -Verbose
I've just encountered the same problem. I've tried many things, but I think the problem stems from having the module SQLPS installed alongside SqlServer module. (SQLPS being an older version of sqlserver).
The steps I used: (probably a little excessive)
Close every application that may have a reference to Powershell
modules. For me this list included Visual Studio, SSMS, SQL Agent,
and of course all Powershell cmd and/or IDE.
Open a Administrator PowerShell command shell.
execute:
Uninstall-Module sqlps
Uninstall-Module sqlserver
Check the Powershell modules folder to make sure you've cleared the modules.
The place to look is:
ls "c:\program files\WindowsPowerShell\Modules"
Both of the folders "sqlps" and "sqlserver" should be missing or empty.
Now re-install sqlserver module:
Install-Module sqlserver
Check that you have the Write-SqlTableData:
Get-Command -module sqlserver
In case you suspect you have an error with versioning: I have tried and tested sqlserver module versions: 21.1.18218 & 21.0.17099

Executing batch script from ansible control host does not work properly

I have following very simple batch script to install Visual Basic 2017 Build Tools.
C:\packages\visualstudio2017buildtools\vs_buildtools.exe --add Microsoft.VisualStudio.Workload.DataScience --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.NetCoreTools --add Microsoft.VisualStudio.Workload.Universal --includeOptional --includeRecommended --noweb --quiet
When I execute this script locally on the server, everything works as expected while executing it from ansible control host does not install the software. Tried many things e.g. invoke script from ansible control host and also tried to execute it locally after copying it to the remote server. It looks like the script is executing and copies few dlls from the installer but never installs the actual software/components.
Any idea what I maybe missing?
Example ansible task:
- name: Invoke batch script to install Build Tools
win_command: install.bat
args:
executable: cmd
chdir: '{{ buildtools_dst_dir }}\visualstudio2017buildtools\'
creates: '{{ buildtools_dst_dir }}\do_not_run_buildtools\'
Update:
It looks like I was missing --wait parameter in batch script when running from ansible. Adding that solved the issue.

A command in a .bat file is unrecognized when the .bat file is called from an Inno Setup but works fine when I run the bat file manually

I have the following .bat file:
fbwfmgr /enable
.
.
.
fbwfmgr /addexclusion c: "some folder 1"
fbwfmgr /addexclusion c: "some folder 2"
.
.
.
which I'm calling from the [Run] section in my Inno Setup like this:
Filename: "{tmp}\set_write_protection_rules.bat";
I have also tried this:
Filename: "{cmd}"; Parameters: "/c ""{tmp}\set_write_protection_rules.bat""";
I always get the message
'fbwfmgr' is not recognized as an internal or external command, operable program or batch file.
If I run the .bat file by double clicking on it it works, if I run it from a cmd window myself it works. What am I missing here?
I'm running this on a Windows Embedded Standard x64 system logged in as the administrator.
EDIT:
Adding the full path to the fbwfmgr.exe does not solve the issue (I have also manually looked that that's the actual location of fbwfmgr.exe):
%systemroot%\system32\fbwfmgr.exe /enable
I found a similar thread here where the OP is having the same problem while running the .bat file from vbs, no solution seems to have been found there. From a suggestion there to cut the middle man I've tried calling fbwfmgr directly from Inno Setup with the following line:
Filename: "{cmd}"; Parameters: "c/ ""fbwfmgr /enable""";
but to no use. It just opens an empty console window. When I try to call fbwfmgr from there, it is not recognized.
Isn't it, because there's only 64-bit version of the fbwfmgr in the C:\Windows\System32 on the system?
As Inno Setup in a 32-bit application, it by default gets redirected to C:\Windows\SysWOW64 (32-bit version of C:\Windows\System32). If there's no 32-bit version of fbwfmgr in the C:\Windows\SysWOW64, Inno Setup cannot find it.
Add the Flags: 64bit to make Inno Setup find 64-bit version of the fbwfmgr.
Also, there's no point running a .exe application via a command interpreter (cmd.exe).
[Run]
Filename: "fbwfmgr.exe"; Parameters: "/enable"; Flags: 64bit
With a batch file, the mechanics is bit more complicated. Inno Setup by default (being a 32-bit applications) runs a 32-bit cmd.exe, which in turns looks into the C:\Windows\SysWOW64. If you add the Flags: 64bit, Inno Setup will run a 64-bit cmd.exe, which will look into the C:\Windows\System32.
[Run]
Filename: "{tmp}\set_write_protection_rules.bat"; Flags: 64bit
Or use the 64-bit install mode.
For a similar question, see PowerShell script executed from Inno Setup is failing with "Retrieving the COM class factory for component with CLSID {XXXX} failed - error 80040154".
You probably need to provide the path to fbwfmgr.
e.g.
"C:\Users\JOHNDOE\SomeDir\fbwfmgr“
Note
You will almost certainly need to run the batch script with administrative privileges too! I know you said you are logged in as the administrator, but you need to be certain that you have the permission for the script to be running especially as you are running it from another application, (inno).

Resources