![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to delete a Windows Service? Hello everyone, My following code could correctly enumerate all the services on my local machine, but how to remove/uninstall a service by its name? I found quite some time in MSDN for ServiceController, but failed to find one. Any ideas? foreach ($ServiceItem in Get-Service) { $ServiceItem.DisplayName } regards, George |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to delete a Windows Service? Thanks Shay, It works cool! A further question, I have also used the wmi object to retrieve the executable path name. by using the PathName property. But it contains both the executable name and related parameters like "C:\Windows\system32\svchost.exe -k LocalService". How to get only the executable binary name (I just want C:\Windows\system32\svchost.exe)? regards, George |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to delete a Windows Service? Hello George, Try with WMI: $svc = gwmi win32_service -filter "name='alerter'" $svc.delete() Beware, there is no turning back or any confirmation messages. --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic G> Hello everyone, G> G> My following code could correctly enumerate all the services on my G> local machine, but how to remove/uninstall a service by its name? I G> found quite some time in MSDN for ServiceController, but failed to G> find one. Any ideas? G> G> foreach ($ServiceItem in Get-Service) G> { G> $ServiceItem.DisplayName G> } G> regards, G> George |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to delete a Windows Service? Use IndexOf() to find the first space position and then substring() to return all characters until that position: PS > $svc = gwmi win32_service -filter "name='alerter'" PS > $svcFilePath = $svc.pathName.substring(0,$svc.pathName.indexOf(" ")) PS > $svcFilePath C:\WINDOWS\system32\svchost.exe You can also use the split() method and return the first index item (e.g 0 position), split() breaks the string on the space character by default: PS > $svc.pathName.split()[0] C:\WINDOWS\system32\svchost.exe --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic G> Thanks Shay, G> G> It works cool! A further question, I have also used the wmi object to G> retrieve the executable path name. by using the PathName property. G> But it contains both the executable name and related parameters like G> "C:\Windows\system32\svchost.exe -k LocalService". How to get only G> the executable binary name (I just want G> C:\Windows\system32\svchost.exe)? G> G> regards, G> George |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How to delete a Windows Service? Thanks Shay, I like your reply! :-) regards, George |
My System Specs![]() |
| | #6 (permalink) |
| | Re: How to delete a Windows Service? Hi Oisin, I read through the information you posted for sc. Which option do you mean could serve my purpose? I read through but none of them dealing with executable path name. Any ideas? regards, George |
My System Specs![]() |
| | #7 (permalink) |
| | Re: How to delete a Windows Service? On Aug 26, 2:46*am, George <Geo...@xxxxxx> wrote: Quote: > Hi Oisin, > > I read through the information you posted for sc. Which option do you mean > could serve my purpose? I read through but none of them dealing with > executable path name. Any ideas? > > regards, > George C:\>sc.exe qc w3svc [SC] QueryServiceConfig SUCCESS SERVICE_NAME: w3svc TYPE : 20 WIN32_SHARE_PROCESS START_TYPE : 2 AUTO_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : C:\Windows\system32\svchost.exe -k iissvcs LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : World Wide Web Publishing Service DEPENDENCIES : WAS : HTTP SERVICE_START_NAME : LocalSystem |
My System Specs![]() |
| | #8 (permalink) |
| | Re: How to delete a Windows Service? "George" <George@xxxxxx> wrote in message news:1E539DAE-8356-4932-8917-DC32E3DA3603@xxxxxx Quote: > Hi Oisin, > > > I read through the information you posted for sc. Which option do you mean > could serve my purpose? I read through but none of them dealing with > executable path name. Quote: > Any ideas? has to be done that way? E.g. why not do it by service name? Then you could use sc config, stop, and delete (if desired) to control it. ; ) --- |
My System Specs![]() |
| | #9 (permalink) |
| | Re: How to delete a Windows Service? Thanks Robert! My situation is, I have installed multiple my self cooked monitor service, called TestMonitor1, TestMonitor1.1 and TestMonitor1.3. I want to list all the services which contains name "TestMonitor" and delete all matched ones. So, I can not use an exact name. Any ideas to my question? regards, George |
My System Specs![]() |
| | #10 (permalink) |
| | Re: How to delete a Windows Service? "George" <George@xxxxxx> wrote in message news:5E3BEE4D-598A-40E5-8594-7F32F18EC2A5@xxxxxx Quote: > Thanks Robert! > > > My situation is, I have installed multiple my self cooked monitor service, > called TestMonitor1, TestMonitor1.1 and TestMonitor1.3. I want to list all > the services which contains name "TestMonitor" and delete all matched ones. > So, I can not use an exact name. > > Any ideas to my question? E.g. see if this command would list what you want to see: tasklist /svc /fi "Imagename eq <your host>" Good luck Robert ---- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| delete a non existent service | Vista General | |||
Service (how to delete) | Drivers | |||
| how do i delete a disabled service ? | PowerShell | |||
| can someone plz explain to me how to delete a service? | PowerShell | |||