Windows service does not stop and not deleted on uninstall (Wix) - windows-services

I've seen a few related questions on stackoverflow that relate to this one, but none of them seem to address the specific behavior I'm observing.
I have a Windows Service defined as follows in a Wix 3.0 .wxs file.
<Component Id='Service' Guid='3c658a54-b236-11e0-bbf6-039615e482ae' >
<File Id='ServiceEXE' Name='m_agent_service.exe'
Vital='yes' Source='..\m_agent_service.exe'
KeyPath='yes' />
<ServiceInstall Id='MerakiServiceInstall'
Vital='yes'
Name='MerakiPCCAgent' DisplayName='Meraki Client Insight Agent $(env.VERSION)' Description="Meraki Client Insight Monitoring and Management Service"
Type='ownProcess' Interactive='no' Start='auto' ErrorControl='normal'>
</ServiceInstall>
<ServiceControl Id='MerakiServiceControl'
Name='MerakiPCCAgent'
Start='install' Stop='both' Remove='uninstall'
Wait='yes' />
</Component>
When I install the .MSI, the service is installed and running. Great.
When I then uninstall (either by running msiexec /x or using the Add/Remove Software from the Control Panel), the service keeps on running and is not removed. In fact, the log of the service itself tells me that none of the service shutdown code has been invoked. (When I use "sc stop", for example, I do see service shutdown code running cleanly.)
Here are some salient parts from the msiexec /x uninstall log:
MSI (s) (14:04) [11:33:54:692]: 1 application(s) had been reported to have files
in use.
Info 1603. The file C:\Program Files\Meraki\PCC Agent 1.0.67\m_agent_service.exe
is being held in use by the following process: Name: m_agent_service, Id: 3120,
Window Title: '(not determined yet)'. Close that application and retry.
MSI (c) (40:78) [11:33:54:692]: File In Use: -m_agent_service- Window could not
be found. Process ID: 3120
MSI (c) (40:78) [11:33:54:692]: No window with title could be found for FilesInUse
[...]
Action start 11:33:57: UnpublishFeatures.
MSI (s) (14:04) [11:33:57:379]: Doing action: StopServices
MSI (s) (14:04) [11:33:57:379]: Note: 1: 2205 2: 3: ActionText
Action ended 11:33:57: UnpublishFeatures. Return value 1.
Action start 11:33:57: StopServices.
MSI (s) (14:04) [11:33:57:379]: Doing action: DeleteServices
MSI (s) (14:04) [11:33:57:379]: Note: 1: 2205 2: 3: ActionText
Action ended 11:33:57: StopServices. Return value 1.
Action start 11:33:57: DeleteServices.
MSI (s) (14:04) [11:33:57:379]: Doing action: RemoveFiles
[...]
MSI (s) (14:04) [11:33:57:645]: Product: Meraki Client Insight Agent -- Removal
completed successfully.
MSI (s) (14:04) [11:33:57:645]: Windows Installer removed the product. Product N
ame: Meraki Client Insight Agent. Product Version: 1.0.67. Product Language: 103
3. Removal success or error status: 0.

Oh dear, whilst on the loo I had a brainwave and I think I have fixed it myself after all – sorry for the post! I think I shall explain what fixed it though in case any other beginners following the same Wix book as me run into the same issue.
Basically, I changed the Guid on my component, reinstalled, uninstalled and it all worked again. (I take on board that changing Guids may not be best practice, but this worked for me.)
To elaborate, I think there was actually no problem at all with my installer – the problem was on the PC I was using to test the installation. My first attempt at installing this windows service was done with no ServiceControl element, just the ServiceInstall element. I then tested the install, and it worked, but the service didn’t remove itself on uninstall, obviously. I then manually stopped and uninstalled the service from my PC using Services.msc.
I then read the next section of my book, realised I also needed a ServiceControl element, created it and re-tried the installer – but I was using the same Guid. The uninstall still didn’t work correctly and I assumed I’d done something wrong in my installer, hence the post above.
What I’m guessing had happened is that the previous install, using the same Guid but without the ServiceControl element, caused my PC to get corrupted somehow and prevented the new uninstaller from completing properly.
Let this be a lesson to me – never test your installer on your own PC! One of those rules I fully understand and happily ignore, till it bites me :)

Check the verbose log file and ensure the Component is being changed. It is possible the Feature is turned off or a Component/Condition is causing the Component to be skipped.

Related

Process with an id of x is not running (Visual studio 2017)

UPDATED BELOW
I have went trough several (if not all) posts mentioning this error on SO and google, but still having this issue. The error I get is:
Process with an id of x is not running
In addition I can notice this error in my VS output window as well:
The program '[11392] iisexpress.exe' has exited with code 0 (0x0).
The program '[11392] iisexpress.exe: Program Trace' has exited with code 0 (0x0).
Where the number is always the same as the PID mentioned in the original error.
I have checked and no, the PID is not used by any process, I have done a ton of stuff like proposed in here, here, here, here and some others ...
This is for all my Web projects (newly created from scratch or old ones).
So with a WPF for example this is working fine.
So this must be something IIS related i think, uninstalled it, reinstalled it had not effect, neither did renaming/removing the IISEXPRESS folder in documents or checking all options in CPanel => Turn features on/off for the IIS options and tons of other things I tried like adding environment variable
_CSRUN_DISABLE_WORKAROUNDS
run as admin, removing the .vs folder, removing the
IISUrl , DevelopmentServerVPath & DevelopmentServerPort
parts in the .csproj file or checking the
Tools menu > Options > Projects and Solutions > Web Projects > Use the 64 bit version of IIS Express
even uninstalled all my VS versions and reinstalled only 1 VS Enterprise 2017 ...
I'm completely lost here, what's happening?
Any suggestion is welcome!
UPDATE 1:
I have uninstalled the IISExpress 10 and installed the version 8, still the same issue.
This is what Event viewer is logging:
Log Name: Application
Source: Application Error
Date: 01/06/2019 09:33:00
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: PCName
Description:
Faulting application name: iisexpress.exe, version: 8.0.8418.0, time stamp: 0x4fbae3d6
Faulting module name: ntdll.dll, version: 10.0.17763.475, time stamp: 0x3230aa04
Exception code: 0xc0000008
Fault offset: 0x00000000000a356a
Faulting process ID: 0x2d68
Faulting application start time: 0x01d5184c3d470917
Faulting application path: C:\Program Files\IIS Express\iisexpress.exe
Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
Report ID: cce33ecf-9507-42ab-87bf-9482a39181e9
Faulting package full name:
Faulting package-relative application ID:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2019-06-01T07:33:00.972839500Z" />
<EventRecordID>58319</EventRecordID>
<Channel>Application</Channel>
<Computer>PCName</Computer>
<Security />
</System>
<EventData>
<Data>iisexpress.exe</Data>
<Data>8.0.8418.0</Data>
<Data>4fbae3d6</Data>
<Data>ntdll.dll</Data>
<Data>10.0.17763.475</Data>
<Data>3230aa04</Data>
<Data>c0000008</Data>
<Data>00000000000a356a</Data>
<Data>2d68</Data>
<Data>01d5184c3d470917</Data>
<Data>C:\Program Files\IIS Express\iisexpress.exe</Data>
<Data>C:\WINDOWS\SYSTEM32\ntdll.dll</Data>
<Data>cce33ecf-9507-42ab-87bf-9482a39181e9</Data>
<Data>
</Data>
<Data>
</Data>
</EventData>
</Event>
UPDATE 2:
I have tried running VS 2017 Enterprise in SafeMode and it gives me this error:
I will investigate this error further, please, if anyone has any idea, post it!
I have the same problem. Here are some of the things I've done that haven't worked:
Delete the .vs folder in my project
Delete the IIS Express folder in My Documents
Add _CSRUN_DISABLE_WORKAROUNDS to your environment variable
Restart the computer
Restart Visual Studio
Change the port
Even re-install visual studio
Uninstall IIS 10.0 Express via Control Panel, then reinstall
I've tried almost all the solutions I got from several forums and none of them have worked.
Finally I found the source of the problem. The source of the problem is not from my project nor from my visual studio, but from my IIS.
When I open iisexpress.exe from C: \ Program Files \ IIS Express, the command prompt closes immediately. If your IIS Express is fine, then what will appear is as shown below.
iisexpress.exe if success
What I do is reset or reinstall IIS Express via Turn Windows Features on or off in Control Panel. And follow the step by step contained in the following link
My worked solution
This is the only way that worked for me, and hopefully it will help the others too.
For me problem was in different version of .net version on machine where i was trying to start project.
VS Solution was created on .net 6.o.5 version and after transferring solution to pc where o.6.4 only installed - issue with process occurs.
After updating .net to correct version issue is gone.
P.S. method with deleting the .vs folder does not help.
P.S.2 VS2022

Nuget gives the error "ps1 cannot be loaded because running scripts is disabled"

I have a new empty MVC 5 project, and I try to install Nuget packages.
When I insert in the Nuget Console the command :Update-Package I got the following asnwer:
File E:\WebApp\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\uninstall.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.At line:1 char:3
+ & 'E:\WebApp\packages\Microsoft.CodeDom.Providers.Dot ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
then I start to install some new packages and got again this message:
WebApp\packages\Modernizr.2.8.3\tools\install.ps1 cannot be loaded because running scripts is disabled on this system
I saw some posts related with this message, but not related with MVC projects.
My question is:
Why I get those messages?
What can I do to fix this issue?
This issue, can appear on the server where my application will run? Some scripts to not run as expected?
I guess the specific package you are trying to install needs to run a Powershell script and for some reason, Powershell execution is disabled on your machine.
You can search google on "how to enable Powershell" for a complete guide but generally, it goes like this:
Open up a Powershell command window (just search for Powershell after pressing windows start button)
Check out current restrictions by typing Get-ExecutionPolicy
Enable PowerShell by typing Set-ExecutionPolicy remotesigned
This issue does not affect the server you are planing to install your application on.
If you encounter this installing NuGet packages from Visual Studio Package Manager Console, run Visual Studio as Administrator.
In case anybody finds this on Google and this happened to you, I suggest you first try restarting Visual Studio, particularly if the Package Manager Console has worked for you before. In VS 2019, I've noticed that, if I leave it in the background while it's loading, sometimes it'll throw that error.
For me, restarting Visual Studio and leaving it in the foreground until the Package Manager Console finished initializing solved the issue. Note that running it as administrator was not necessary.
Translation of the image text would be somewhat: This certificate has been revoked from its key store.
Certificate on my init.ps1 has expired - thus RemoteSigned will not do. For that package version to work, it would need to be set to ByPass or Unrestricted. Personally, i would not recommend doing this...
-- EDIT --
I went ahead and updated the package and found they have resigned a new cert for v 1.0.2. Issue following in NuGet console for fix:
Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
open your power-shell as administration and type
Get-ExecutionPolicy
Expected result RemoteSigned
Set-ExecutionPolicy remotesigned
if it does not work, try Powershell run in administrator
I ran into a similar issue building a project and found that you MAY have to set the execution policy to remoteSigned (as others have mentioned) in BOTH powershell (x86) and powershell (x64). I was running the x64 version as administrator and Get-ExecutionPolicy returned "remoteSigned" but the x86 version hadn't been updated. Just something to try if the above answers don't work for you.
This should work
open your power-shell as administration and type
Get-ExecutionPolicy
Expected result RemoteSigned
Set-ExecutionPolicy remotesigned
Enjoy
A quick to fix this error when using Package Manager Console without VS restart and/or running as Admin is to remove the restriction for current user:
Set-ExecutionPolicy remotesigned -scope CurrentUser

Pass parameter to app config file during MSI installation - Advanced Installer

I have created MSI package using advanced Installer. It contains App Config to which i have to pass the siteURL which varies depending on location. I need to pass the siteurl to app config when msi is installed . Please help me with it. I am new to Advanced Installer
You can check the online user guide for Advanced Installer, it has a lot of useful info. For example the article on importing and editing XML config files.
Or how to add a custom dialog and write in the system the values captured from the end users.
EDIT: additional answer regarding command line
You can run the installation silently from the command line but you will still see the message box saying the package is built with a trial. You will not see the standard MSI dialogs. And the trial messages will be gone once you purchase license for Advanced Installer.
Please note that your command prompt window (cmd.exe) must be launched as administrator, if your installation is installing per-machine (i.e. you write in Program Files or HKLM registry hive). Otherwise the installation will fail silently and you will not know why, because on silent installation the OS will not show an error message.
Here is a command line example:
msiexec.exe /i C:\setup\installer.msi /qn ID="235424" SiteURL="www.example.com"
Please note that it is not recommended to use private properties, i.e. properties with lower case letters in their name, we recommend public properties, for example: SITE_URL.

Windows x64 RabbitMQ install error with Erlang environment var (ERLANG_HOME)

I'm ask/answering this question because it hung me up & it's likely someone else will have the same problem.
Install of RabbitMQ x64 v2.8.6 on Windows Server 2008 x64.
After Erlang install using default install location to C:\Program Files\erl5.9.2, I'm attempting to start the server via running the rabbitmq-service.bat. Fail:
Please either set ERLANG_HOME to point to your Erlang installation
or place the RabbitMQ server distribution in the Erlang lib folder.
Problem is the .bat file does not have the correct subpath. with 5.9.2 (R15B02) version of erlang. My ERLANG_HOME directory is set correctly, but the script does not use it correctly for this version of Erlang, which, it appears to this Erlang noob to have a new subdirectory called "erts-5.9.2" which is causing the problems. Maybe someone intimate with these scripts can describe how to make this work correctly without the hack workaround I'm about to describe?
1- Set environment variable:
Variable name : ERLANG_HOME
Variable value: C:\Program Files (x86)\erl6.4
note: don't include bin on above step.
2- Add %ERLANG_HOME%\bin to the PATH environmental variable:
Variable name : PATH
Variable value: %ERLANG_HOME%\bin
This works well.
There are several RabbitMQ control .bat files on windows. Every one you use needs to get changed to reflect the Erlang path correctly. In this example, I'm editing the rabbitmq-server.bat because it's one of the easier ones... any of the .bat files you want to run will need this hack to get them to work, with the rabbitmq_service.bat file being the most involved to adjust.
editing that rabbitmq_server.bat file, you can see on about line 48 or so there's a check to see if the erl.exe is found, but the path isn't correct:
if not exist "!ERLANG_HOME!\bin\erl.exe" (
that path does not match the file structure for the 5.9.2 version of Erlang. I fixed this by simply removing this path check from about line 48 to 58, then, where the .bat actually makes a call to the erl.exe on about line 129 which reads:
"!ERLANG_HOME!\bin\erl.exe"
I simply hardcoded the path to my erl.exe:
"C:\Program Files\erl5.9.2\erts-5.9.2\bin\erl.exe"
With the pathing correct, the rabbitmq .bat files will run.
I had the similar issue, modifying ERLANG_HOME in .bat files did not work. Then I tried echo %ERLANG_HOME% in command prompt, that did not print the environment variable value(I could see that ERLANG_HOME environment variable has been created under advance system settings), that lead me to believe that I need to restart server for 64 bit installation of Erlang. After rebooting server, It worked like a charm. I hope this helps someone.
Just to share an up-to-date answer as of 2019: On Windows Server 2019, after setting up the environment variable, a restart is required to solve the problem.
I got into same kind of problem.
I solved it by doing three changes as given below.
Update Path variable "ERLANG_HOME" : "C:\Program Files\erl8.0" in Environment Variables.
Upadte "Path" variable "Path" : ";%ERLANG_HOME%\bin;"
Give urself FULL CONTROL permissions over "Program Files" in C drive.
It worked for me in this way.
This problem still occurs in Erlang 18.3 (erl7.3) and RabbitMQ 3.6.9 on Windows when upgrading from any older version of RabbitMQ to version 3.6.9. The solution as already stated here is to manually set ERLANG_HOME with 'setx -m ERLANG_HOME "C:\Program Files\erl7.3"' before starting the service.
What happens is that the RabbitMQ 3.6.9 installer removes the environment variable ERLANG_HOME from the system while removing the older version of RabbitMQ. Then, when it proceeds to the installation step, it does not put back the ERLANG_HOME variable. Then, the batch files that start up RabbitMQ cannot find Erlang. They try to find Erlang's home directory using "where.exe" but it always fails after an upgrade.
RabbitMQ's installer also does not kill all of the Erlang background processes, causing many of its files to be undeletable due to the Windows "file in use" problem. This leaves behind "files in use" in %APPDATA%\RabbitMQ and "C:\Program Files\RabbitMQ." These processes are "erl.exe," "erlsrv.exe," and "epmd.exe." The RabbitMQ installer should taskkill these processes after shutting down the RabbitMQ Windows service.
RabbitMQ is rather clunky on Windows.
Download Erlang or OTP - Only one Version of OTP should be installed
Download RabbitMQ installer
Install both exe file as Administrator
Set class path for Erlang. (Setting classpath is a bit troublesome, so follow these steps)
Set a new path with name ERLANG_HOME and value C:\Program Files\erl-23.1 (do not copy bin folder here)
Edit System "path" and add %ERLANG_HOME%\bin
Go to Start - Open rabbitmq command promt and run
rabbitmq-plugins enable rabbitmq_management
Navigate to localhost:15672
Use guest/guest to login
Interesting that this worked for you. There is record of a two bugs in Erl5.9.2 that cause an incomplete installation where %ERLANG_HOME%\bin is not installed.
Either of
* Installed 64bit erlang on 32bit machine
* "The program can't start because MSVCR100.dll is missing from your computer."
https://groups.google.com/d/topic/erlang-programming/wGtFLzapiQ0/discussion
Try 5.9.1 or any other version. They also mention making the future versions of the installer alert you if it fails.
I just had the same problem mentioned here. I installed otp_win64_R15B02 on a Windows 7 machine and everything worked perfectly, but I used the same installer on a Windows 2008 server and the bin directory was not created. I then uninstalled otp_win64_R15B02 and downloaded the otp_win64_R15B02_with_MSVCR100_installer_fix and the bin directory was created.
I suspect the reason it worked on my Windows 7 system is that I have Visual Studio installed and the required libraries were already available which allowed the otp_win64_R15B02 installer to work correctly.
Oh, and if you're installing Erlang to run RabbitMQ the RabbitMQ install will succeed with the broken installer but installing otp_win64_R15B02_with_MSVCR100_installer_fix after RabbitMQ will not work, just un-install and re-install RabbitMQ to resolve this.
Just give C:\Program Files\erl10.6\ not C:\Program Files\erl10.6\bin\erl.exe in the environment variable. If you open the server.bat file I came to know the issueenter image description here
I think this is encoding issue on windows.I see a correct value but I write echo %ERLANG_HOME% on console the value come with question mark. These steps fix it.
1.go environment variable window
2.edit ERLANG_HOME item
3.copy the value, open notepad and paste there
4.copy again on notepad and paste to edit window
5.apply and exit window
6.close command line tools and reopen
7.run rabbitmq bat file.
I solved it in a quick and dirty way,without naming path variables
I've opened the bat file and replaced every occurrence of
!ERLANG_HOME!\bin\erl.exe
with hard coded path for example might be diffrent path for you because of diffrent version
C:\Program Files\erl10.3\erts-10.3\bin\erl.exe
and replaced
%RABBITMQ_HOME%\escript\rabbitmq-plugins
with
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.14\escript\rabbitmq-plugins
Even I was this problem. The issue was the environment variable ERLANG_HOME=c:\Program Files\erl9.0 which was never existed.
I cross checked the path. The correct path was c:\Program Files\erl9.3.
After correcting the
ERLANG_HOME=c:\Program Files\erl9.3
the problem solved. So, definitely it is a path issue.
In my case, it should be installed erlang using admin role running
If above solutions doesn't work for you then you can try following
Find another compatible version of erlang for your rabbit mq e.g. for rabbit 3.7.x erlang version 20.3.x to 22.0.x all are compatible .
Right click newly downloaded erlang version and from properties select the option to unblock the file .
Run the erlang with admin persssion .
Re run rabbit mq exe

the installed product does not match the installation source(s) error when uninstalling a windows service

when I try to uninstall a windows service from the control panel, I am getting error "the installed product does not match the installation source(s), until a matching source is provided or the installed product and the source are synchronized, this action cannot be performed". actually I do have the original MSI file, but I modified some settings in the config file (where it is installed) after installation, so that might have caused it, how can I uninstall it now?
The MSI you think is the original probably isn't really. It sounds like you got yourself in a situation where PackageCode ( GUID ) A is installed and now you have an MSI with PackageCode B.
Take the MSI you have and run the following command:
MsiExec.exe /I foo.msi REINSTALLMODE=voums REINSTALL=ALL
This will "recache" the MSI with the updated PackageCode. You should then be able to uninstall either through Add Remove Programs ( Programs and Features ) or with the command
MsiExec.exe /X foo.msi

Resources