cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOW TO: Stop a Windows Service using a Custom Action

HOW TO: Stop a Windows Service using a Custom Action

Summary

This article will discuss one possible method of manually closing a Windows Service using a custom action.

Synopsis


This article will discuss one possible method of manually closing a Windows Service using a custom action.


Discussion


To manually stop a windows service create the following Custom Action:
Type: New EXE , Path referencing a directory
Working Directory: SystemFolder
File Name and Command Line: cmd.exe /c "[WindowsFolder]system32\sc.exe stop NAME_OF_SERVICE"
Return Processing: Synchronous (Check Exit code)
In-Script Execution: Immediate Execution
Custom Action to Stop a Windows Service

Note: Closing Windows Services will require elevated privileges, the MSI will not elevate itself until after the InstallValidate action. Therefore care should be taken to place this custom action after InstallValidate if using a single MSI release.


If this custom action must be placed before InstallValidate we can force the MSI to run with elevated priviledges from the outset by using a Setup Launcher.
Within the setup.exe tab of your release make sure that the "Required Execution Level" is "Administrator".
This will force the setup.exe to request Admin priviledges which are then carried over to the MSI allowing the custom action to run earlier than InstallValidate.

Additional Information


Further information regarding the SC tool including its parameters can be found in the following Microsoft article:
http://support.microsoft.com/kb/251192


Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Jun 07, 2018 02:09 AM
Updated by: