windows service not deleted on uninstall (WIX 3) - service

I have created the setup with WIX installer 3, which installs windows service.
It installs the service fine but when i uninstall it the service not removed.
I'm using ServiceInstall and ServiceControl.
i'm using the servicecontrol only for uninstalling the service and not for start.
although uninstall process run smoothly, the service is not deleted.
Log doesn't show errors.
Folder is empty of files after finishing
uninstall.
the service is not running during uninstall - so no issue
of stuck process.
the setup run on clean environment which i preserved in advance.
i already tried replacing all GUID of all components in my setup.
can some one point on what i'm doing wrong in the code or suggest another solution.
Here is the code:
Component Id="ServiceComponentMain" Guid="{B652D08C-B99D-4CAC-9BCB-A48DF2356C9B}">
<File Id="ApiProxy.Service.exe" KeyPath="yes" Source="$(var.BasePath)\ApiProxy.Service.exe" />
<ServiceInstall
Id="ServiceComponentMain"
Type="ownProcess"
Vital="yes"
Name="ApiProxy"
DisplayName="ApiProxy"
Start="auto"
Account="LocalSystem"
ErrorControl="critical"
Interactive="no"/>
<ServiceControl Id="StartService" Name="ServiceComponentMain" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
and here is the log:
Action ended 13:51:46: InstallInitialize. Return value 1.
MSI (s) (84:18) [13:51:46:547]: Doing action: ProcessComponents
Action 13:51:46: ProcessComponents. Updating component registration
Action start 13:51:46: ProcessComponents.
1: Updating component registration
Action ended 13:51:46: ProcessComponents. Return value 1.
MSI (s) (84:18) [13:51:46:563]: Doing action: UnpublishFeatures
Action 13:51:46: UnpublishFeatures. Unpublishing Product Features
Action start 13:51:46: UnpublishFeatures.
UnpublishFeatures: Feature: Unpublishing Product Features
Action ended 13:51:46: UnpublishFeatures. Return value 1.
MSI (s) (84:18) [13:51:46:568]: Doing action: StopServices
Action 13:51:46: StopServices. Stopping services
Action start 13:51:46: StopServices.
StopServices: Service: Stopping services
Action ended 13:51:46: StopServices. Return value 1.
MSI (s) (84:18) [13:51:46:577]: Doing action: DeleteServices
Action 13:51:46: DeleteServices. Deleting services
Action start 13:51:46: DeleteServices.
DeleteServices: Service: Deleting services
Action ended 13:51:46: **DeleteServices. Return value 1**.
MSI (s) (84:18) [13:51:46:662]: Doing action: RemoveFiles
Action 13:51:46: RemoveFiles. Removing files
Action start 13:51:46: RemoveFiles.
MSI (s) (84:18) [13:51:46:664]: Note: 1: 2205 2: 3: RemoveFile
RemoveFiles: File: Removing files, Directory:
MSI (s) (84:18) [13:51:46:677]: Note: 1: 2205 2: 3: RemoveFile
Action ended 13:51:46: RemoveFiles. Return value 0.
MSI (s) (84:18) [13:51:46:678]: Doing action: RemoveFolders
Action 13:51:46: RemoveFolders. Removing folders
Action start 13:51:46: RemoveFolders.
RemoveFolders: Folder: Removing folders
Action ended 13:51:46: RemoveFolders. Return value 1.

The name given in the ServiceControl element should match the name of the service as given in the ServiceInstall element.

Related

Add-SBHost : The system cannot find the file specified

I am attempting to add a Host to a newly created Windows Service Bus 1.1 farm but regardless of what I do I eternally get the following error:
VERBOSE: [11/16/2018 2:54:06 PM]: Validating input and configuration parameters.
VERBOSE: [11/16/2018 2:54:06 PM]: Installing auto-generated certificate.
VERBOSE: [11/16/2018 2:54:16 PM]: Granting 'Log on as Service' privilege to the run as account.
VERBOSE: [11/16/2018 2:54:16 PM]: Windows Fabric configuration started.
VERBOSE: [11/16/2018 2:54:28 PM]: Windows Fabric cluster manifest generated.
VERBOSE: [11/16/2018 2:54:28 PM]: Running Windows Fabric deployment.
Add-SBHost : The system cannot find the file specified
At line:1 char:1
+ Add-SBHost -SBFarmDBConnectionString "Data Source=MYHOST;Initial C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-SBHost], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.ServiceBus.Commands.AddSBHost
I had been struggling with configuring the initial deployment of the farm because my organization uses Azure AD. I was following this very helpful Blog post to get through the installation and deployment but the issue I am seeing now isn't covered.
A Google of the issue leads me to this page where they talk about inspecting a DLL. I tried inspecting the Microsoft.ServiceBus.Commands.dll from within the Service Bus installation folder but, I'll be honest, I didn't understand enough to know what I was looking for.
Has anyone else run into this issue before? All suggestions of where I can look to find this are very much appreciated!
Based on my research of what is actually happening in Add-SBHost command, this error may occur when:
Code is trying create new temp file in %userprofile%\AppData\Local\Temp directory for something called "ClusterManifest".
Code is trying to execute FabricDeployer.exe (with created "ClusterManifest" file path as parameter) in directory which is defined in registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Service Bus\1.1 for variable WinFabric in folder bin\Fabric\Fabric.Code.1.0. In my case, executable was placed in C:\Program Files\Windows Fabric\bin\Fabric\Fabric.Code.1.0\FabricDeployer.exe
Code is trying to remove temp file (created in 1 point) from %userprofile%\AppData\Local\Temp
After that steps and getting message VERBOSE: [09.08.2019 13:32:26]: Windows Fabric starting. no more file operations should be performed.
What to do?
First of all check if temp file is created in %userprofile%\AppData\Local\Temp directory (sort files by modification date in explorer, run script and wait) - probably file cannot be created because of lack of permissions.
If file is creating properly and has XML inside, then check if Service Fabric is installed and FabricDeployer.exe is present in directory. In my case it wasn't there so i had to remove Windows Fabric and Service Bus. After next installation i made sure that all files were in place.
After these steps script run was successful.
I hope it will help you :)

uninstaller doesn't delete all installed files

We have a strange problem during our uninstall process.
After the uninstaller finishes, the user custom sources and some parts of the jre are still present on the system. In the uninstaller.log it states the postponed deletion of some of these files, but not all of them.
Has someone an idea why the deletion is postponed and why they are not deleted at all?
Additionally that doesnt happen on all systems, but is reproducable per system. For example on my developer machine everything works fine, but on a fresh vm the problem occurs.
[INFO] com.install4j.runtime.beans.actions.UninstallFilesAction [ID 29]: Execute action
executing auto uninstall
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\rt.jar
postponing deletion of C:\Program Files (x86)\mytool\.install4j\user.jar
postponing deletion of C:\Program Files (x86)\mytool\.install4j\i4jruntime.jar
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\resources.jar
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\jsse.jar
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\charsets.jar
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\jce.jar
postponing deletion of C:\Program Files (x86)\mytool\jre\lib\jfr.jar
postponing deletion of C:\Program Files (x86)\mytool\.install4j\user\myaction.jar
Execute action successful after 717 ms
my first guess was that it has something to do with the user action. but this is part of the automatic updater which is not executed at all.
edit:
after adding an action "Check for running processes" it is still the same behaviour.
[INFO] com.install4j.runtime.beans.actions.misc.CheckRunningProcessesAction [ID 738]: Execute action
Property additionalExecutables: null
Property closeStrategy: Allow soft close
Property message: install4j hat entdeckt, dass mytool zur Zeit ausgeführt wird.
Bitte schließen Sie jetzt die folgenden Instanzen, und klicken Sie auf "Wiederholen", um fortzufahren, oder auf "Abbrechen", um zu beenden.
Property timeOut: 5000
Property allowIgnore: false
Property includeLaunchers: true
Property rollbackSupported: true
Execute action successful after 0 ms
My assumption from this log message is, there were no running processes, as the action is completed after 0 seconds?
This means that a launcher that is using the bundled JRE is still running. Some files in the JRE are locked in that case and they cannot be deleted.
Use a "Check for running processes" action in the uninstaller to shut down all launchers before the "Uninstall files" action is executed.

Getting an error while upgrading an MSI application

I'm getting below error while upgrading one software on my Windows 2003 server.
"Error 1260 : Windows cannot open this program because it has been prevented by a software restriction policy. For more information, open event viewer."
I searched lot on internet and one thing I got to know that, this error occurs because of one Windows's security update, KB2918614. I uninstalled that update & tried upgrade of my product, it worked fine for me.
But my question is, without uninstalling that update how I can make my upgrade of software successful ?
Here are some logs that I'm getting while failure :
MSI (s) (E4:24) [10:39:07:097]: SECREPAIR: Hash Database: C:\WINDOWS\Installer\SourceHash{97353D18-281D-42B5-8855-21E08089EFB8}
MSI (s) (E4:24) [10:39:07:128]: SECREPAIR: CryptAcquireContext succeeded
MSI (s) (E4:24) [10:39:07:878]: SECREPAIR: filename: **********.msi Stored Hash Value:+VE6k8PVr******************RjSWBjatbw= Current Hash:jhsyK1CivGh*************V2MlyUZsICUx83w=
MSI (s) (E4:24) [10:39:07:878]: SECREPAIR: UAC not supported and could not take approval from user
MSI (s) (E4:24) [10:39:07:878]: SECUREREPAIR: SecureRepair Failed. Error code: 4ec4E6A3388
Finally I got the answer !!
There is one more update Microsoft provided to get rid from current security update KB2918614. Here is the Microsoft article
In this article they have mentioned some registry changes. After doing those change my issue got resolved. Here are those registry changes :
Locate and then click the following subkey in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer
On the Edit menu, point to New, and then click DWORD Value.
Type SecureRepairPolicy for the name of the DWORD, and then press Enter.
Right-click SecureRepairPolicy, and then click Modify.
In the Value data box, type 2, and then click OK.
Locate and then click the following subkey in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer
On the Edit menu, point to New, and then click Key.
Type SecureRepairWhitelist for the name of the key, and then press Enter.
Double-click the SecureRepairWhitelist key to open it.
On the Edit menu, point to New, and then click String Value. Create String Values that contain the product codes (including braces {}) of the products that have to be added to the Safe Recipients list.

Why Msbuild task failed to deploy database, but Exec work fine

I'm trying to deploy database project ( dbproj format, not new SSDT sqlproj ) inside automated build server processing. I found the following:
When I'm calling deploy with Exec task in my Msbuild script - everything working fine:
<Exec Command="$(MSBuildPath)\MSBuild.exe $(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj
/t:Deploy
/p:OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\
/p:TargetDatabase=$(DeployDatabaseName)
/p:TargetConnectionString=$(DeployDatabaseConnectionString)" />
But when I try to repeat this with Msbuild task - it behaves differently:
<MSBuild Projects="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj"
Targets="Deploy"
Properties="Configuration=$(BuildConfiguration);
TargetDatabase=$(DeployDatabaseName);
TargetConnectionString="$(DeployDatabaseConnectionString)";
OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\;
" />
Msbuild task broke on semicolons in DeployDatabaseConnectionString:
<DeployDatabaseConnectionString>Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False</DeployDatabaseConnectionString>
It will report something like this:
The name "Integrated Security" contains an invalid character " ".
But if I replace semicolons with percent encoding value - %3B - it will broke inside SqlDeployTask:
error MSB4018: The "SqlDeployTask" task failed unexpectedly.
What is the proper way to pass TargetConnectionString to Deploy target of SqlProject ?
PS: I Could live with exec task fine, but make a call to msbuild.exe inside msbuild script just hurts my inner perfectionist man.
I found the proper way - new Msbuild allow to define AdditionalProperties metadata on item. So with this feature everything work fine and have no problems with escaping\encoding
<ItemGroup>
<DbProjectToBuild Include="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj">
<AdditionalProperties>Configuration=$(BuildConfiguration)</AdditionalProperties>
<AdditionalProperties>OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\</AdditionalProperties>
<AdditionalProperties>TargetDatabase=$(DeployDatabaseName)</AdditionalProperties>
<AdditionalProperties>TargetConnectionString="Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False"</AdditionalProperties>
</DbProjectToBuild>
</ItemGroup>
<MSBuild Projects="%(DbProjectToBuild.Identity)" Targets="Build;Deploy" />

Breaking MsBuild package & deploy into separate MsBuild and MsDeploy commands

I'm having a few problems breaking out an MsBuild package+deploy command into two separate commands. (I need to do this to pass additional parameters to MsDeploy).
The command that works fine looks like this:
msbuild "src\Solution.sln"
/P:Configuration=Deploy-Staging
/P:DeployOnBuild=True
/P:DeployTarget=MSDeployPublish
/P:MsDeployServiceUrl=https://192.168.0.1:8172/MsDeploy.axd
/P:DeployIISAppPath=staging.website.com
/P:AllowUntrustedCertificate=True
/P:MSDeployPublishMethod=WmSvc
/P:CreatePackageOnPublish=True
/P:UserName=staging-deploy
/P:Password=xyz
The separated packaging command looks like this:
msbuild "src\Solution.sln"
/P:Configuration=Deploy-Staging
/P:DeployOnBuild=True
/P:DeployTarget=Package
/P:_PackageTempDir=C:\temp\web
which works fine. But then the MsDeploy portion:
msdeploy
-verb:sync
-allowUntrusted
-usechecksum
-source:manifest=
'src\WebProject\obj\Deploy-Staging\Package\WebProject.SourceManifest.xml'
-dest:auto,ComputerName=
'https://192.168.0.1:8172/MsDeploy.axd?site=staging.website.com',
username='staging-deploy',password='xyz',authType='basic',includeAcls='false'
-enableRule:DoNotDeleteRule
fails, with the following error in WmSvc.log
wmsvc.exe Error: 0 : Attempted to perform an unauthorized operation.
setAcl/C:\temp\web (Read)
ProcessId=15784
ThreadId=31
DateTime=2011-03-30T14:57:02.4867689Z
Timestamp=3802908721815
wmsvc.exe Error: 0 : Not authorized.
Details: No rule was found that could authorize user 'staging-deploy',
provider 'setAcl', operation 'Read', path 'C:\temp\web'.
(and several more Read/Write operations)
Something is clearly going wrong with the paths it's trying to access (as it works fine with the other method) - I'm not sure it's even trying to use the iisApp targeting correctly, and at the moment I don't think the correct web.config's will be deployed either.
I've got this fixed now - I needed a different command to the one the automatically generated .cmd file was using, but comparing the two allowed me to fix it up (thanks #Vishal R. Joshi)
The differences I needed was:
basic authentication
allow untrusted certificates
?site=staging.webserver on the end of the MsBuild.axd path, as with my original command
override the IIS Web App name that is set in the params file
enable the do not delete rule
The winning command is as follows:
msdeploy
-verb:sync
-allowUntrusted
-source:package='src\WebProject\obj\Deploy-Staging\Package\WebProject.zip'
-dest:auto,ComputerName=
'https://192.168.0.1:8172/MsDeploy.axd?site=staging.website.com',
username='staging-deploy',password='xyz',authType='basic',includeAcls='false'
setParamFile:
"src\WebProject\obj\Deploy-Staging\Package\WebProject.SetParameters.xml"
-setParam:name='IIS Web Application Name',value='staging.website.com'
-enableRule:DoNotDeleteRule
-disableLink:AppPoolExtension -disableLink:ContentExtension
-disableLink:CertificateExtension
Hope this helps someone!
Add a delegation rule on the server using inetmgr to allow staging-deploy to carry out set-Acl operations.
Inetmgr -> Click on server node -> Management Service Delegation (in Management) -> Click Add rule to the right -> Choose the template labelled "Set Permissions for Applications" -> Accept defaults and click OK.
This should let you deploy any package or manifest with setAcl as long as the user you are deploying as, has permissions to the site you are deploying to.
You are able to specify the -setParam:name='',value='' flag when calling the MyProject.deploy.cmd file that is created when you generate a Package from a web project. The cmd is a friendly wrapper around msdeploy.exe, so you have no need to specify all the rest of the defaults.
Here's the details: http://evolutionarydeveloper.blogspot.co.uk/2013/05/specifying-environment-variables-at.html