Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.


Go Back   Vista Forums > Misc Newsgroups > PowerShell

RB

Vista - can someone plz explain to me how to delete a service?

Reply
 
01-13-2008   #1
show3r


 
 

can someone plz explain to me how to delete a service?

can someone plz explain to me how to delete a service?

its not described if i type help service

ty

My System SpecsSystem Spec
01-13-2008   #2
Shay Levi


 
 

Re: can someone plz explain to me how to delete a service?


You can use WMI to delete an existing service:

$service = get-wmiobject win32_service -filter "serviceName"
$returnValue= $service.delete()


Return Value returns one of the listed values:

0 Success
1 Not Supported
2 Access Denied
3 Dependent Services Running
4 Invalid Service Control
5 Service Cannot Accept Control
6 Service Not Active
7 Service Request Timeout
8 Unknown Failure
9 Path Not Found
10 Service Already Running
11 Service Database Locked
12 Service Dependency Deleted
13 Service Dependency Failure
14 Service Disabled
15 Service Logon Failure
16 Service Marked For Deletion
17 Service No Thread
18 Status Circular Dependency
19 Status Duplicate Name
20 Status Invalid Name
21 Status Invalid Parameter
22 Status Invalid Service Account
23 Status Service Exists
24 Service Already Paused



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> can someone plz explain to me how to delete a service?
>
> its not described if i type help service
>
> ty
>

My System SpecsSystem Spec
01-13-2008   #3
Shay Levi


 
 

Re: can someone plz explain to me how to delete a service?


My -filter parameter wasn't complete, here's the modified one:

$service = get-wmiobject win32_service -filter "name='serviceName'"

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> You can use WMI to delete an existing service:
>
> $service = get-wmiobject win32_service -filter "serviceName"
> $returnValue= $service.delete()
>
> Return Value returns one of the listed values:
>
> 0 Success 1 Not Supported 2 Access Denied 3 Dependent Services
> Running 4 Invalid Service Control 5 Service Cannot Accept Control 6
> Service Not Active 7 Service Request Timeout 8 Unknown Failure 9
> Path Not Found 10 Service Already Running 11 Service Database Locked
> 12 Service Dependency Deleted 13 Service Dependency Failure 14
> Service Disabled 15 Service Logon Failure 16 Service Marked For
> Deletion 17 Service No Thread 18 Status Circular Dependency 19
> Status Duplicate Name 20 Status Invalid Name 21 Status Invalid
> Parameter 22 Status Invalid Service Account 23 Status Service Exists
> 24 Service Already Paused
>
> -----
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
Quote:

>> can someone plz explain to me how to delete a service?
>>
>> its not described if i type help service
>>
>> ty
>>

My System SpecsSystem Spec
01-13-2008   #4
RichS


 
 

RE: can someone plz explain to me how to delete a service?

You can use WMI to delete a service. Use Get-WMIObject and the -Filter
parameter to get the specific service

$s = Get-WmiObject -Class Win32_Service -Filter "Name = 'Spooler'"
$s | Get-Member

You will see there is a Delete method - Its actually listed as a script method

So

$s.Delete()

should remove your service. Be aware that there is no confirm or checking
with WMI methods. The delete will just happen.

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"show3r" wrote:
Quote:

> can someone plz explain to me how to delete a service?
>
> its not described if i type help service
>
> ty
>
My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: can someone plz explain to me how to delete a service?
Thread Forum
delete a non existent service Vista General
Solved Service (how to delete) Drivers
Is someone able to explain ??? Vista networking & sharing
how do i delete a disabled service ? PowerShell
How to delete a Windows Service? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd