This project is read-only.

Stop and uninstall services

Topics: Archive - General
Jan 24, 2014 at 9:45 AM
Dear all,

I'm new on this grate tool, but I can't find a function to stop and uninstall a windows service like "sc delete newserv" with a result if the uninstall was successfully.

My problem is, in a big installation we have to install more than 30 msi packages and within the installation, one or more times a new service was installed and startet.

To make sure the installation works fine, I have to stop and delete a earlier installed service.

I think the tool don't have a function to do this?

Jan 24, 2014 at 5:03 PM

The following should work:
# Name of the service
$serviceName = "MyService"

# Stop the service
Stop-Service $serviceName

# Use WMI to delete the service
$service = Get-WmiObject -Class Win32_Service -Filter "Name='$serviceName'"
Hope this helps, Dan.