Skritek
Posts: 8
Joined: Thu Apr 14, 2011 10:59 am

Stop system service on Uninstall

Hi,
I need to stop service running as the local System Account on uninstall. Which means I need to be running elevated. The service needs to be stopped *before* InstallValidate (That's where the files-in-use check happens, yes?) How can I to accomplish this with Advanced Installer? i have found similar discussion here. But i dont understand the solution.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Stop system service on Uninstall

Hello and welcome to the Advanced Installer Forums,

Here is the link to our step by step article that describes this. To schedule this functionality during uninstall you should set the "Terminate Process" custom action with the following execution condition:

Code: Select all

REMOVE="ALL"
If you have trouble understanding or implementing the functionality from the article, we'll be happy to assist.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Skritek
Posts: 8
Joined: Thu Apr 14, 2011 10:59 am

Re: Stop system service on Uninstall

I think that this article doesnt solve my problem. I need to stop system service, not a process. And I need admin rights to do this. I have made exe which demand admin rights and stops the service. When i run it directly it works. But when I place it as attached custom action on begin event It doesnt work. The service needs to by stopped before "file-in-use'' check .
kkrzyzak
Posts: 47
Joined: Wed Oct 13, 2010 2:10 pm

Re: Stop system service on Uninstall

Hi Skritek,

This can be helpful.

Best,
Karol.
Skritek
Posts: 8
Joined: Thu Apr 14, 2011 10:59 am

Re: Stop system service on Uninstall

kkrzyzak wrote:Hi Skritek,

This can be helpful.

Best,
Karol.
Thanks. But I think that the script cant help me. Because I need to run it before InstallValidate (before file-in use check ) . And I need to by running elevated ( with no impersonation). This is probably not posible with custom actions.

Code: Select all

option explicit
Dim objFSO
Set objFSO = CreateObject("WScript.Shell")
objFSO.run("net stop ""ServiceName""")
I have tried to run my .exe wich stops the service. This is the result.

MSI (s) (B8:8C) [14:45:45:137]: Running ExecuteSequence
MSI (s) (B8:8C) [14:45:45:137]: Doing action: stop_icproxy.exe
Action 14:45:45: stop_icproxy.exe.
Action start 14:45:45: stop_icproxy.exe.
MSI (s) (B8:8C) [14:45:45:278]: Note: 1: 1721 2: stop_icproxy.exe 3: C:\Windows\Installer\MSIDEC1.tmp 4:
Info 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: stop_icproxy.exe, location: C:\Windows\Installer\MSIDEC1.tmp, command:
Action ended 14:45:45: stop_icproxy.exe. Return value 1.

When i run it directly it works.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Stop system service on Uninstall

Hello,

You can try to use the sc command line utility. Just set this utility as a "Launch File or Open URL" custom action before InstallValidate:

Source Path: <AI_CUSTACTS>viewer.exe
Source Type: Executable
Command Line: sc Stop <YourServiceName>

To run this custom action during uninstall, you should set it with the following execution condition:

Code: Select all

REMOVE="ALL"
In the end you would need to run the package elevated, hence you should also check the "Create .EXE setup file" option in the Bootstrapper tab from the Media Page and select the "Require Administrator" execution level.

Let us know how it turned out.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Skritek
Posts: 8
Joined: Thu Apr 14, 2011 10:59 am

Re: Stop system service on Uninstall

Thanks, this seems to be working :D

Return to “Common Problems”