Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to remove a service or change the startup type to disabled

Reply
Thread Tools

How to remove a service or change the startup type to disabled

 
 
Matt Rapoport
Guest
Posts: n/a
 
      08-29-2003
I'd like to programmatically remove a service or change its startup
type to disabled. I know how to remove it from the command line but
is there another way using the win32 extensions?

I've looked through the win32 help file but when it lists the
arguments for its methods (such as win32service.ChangeServiceConfig)
it doesn't give a dictionary of possible arguments. How can I tell
what int is associated with what Access Type (in OpenService), for
example.

Any help would be appreciated.

Thanks,

Matt
 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      09-01-2003
(Matt Rapoport) wrote in message news:<. com>...
> I'd like to programmatically remove a service or change its startup
> type to disabled. I know how to remove it from the command line but
> is there another way using the win32 extensions?


Three answers:

1) The win32service module has a load of constants
for this sort of purpose. Do dir (win32service)
and look for things in capitals. At the moment,
I'll leave anyone else on the list who's had experience
of this to answer specifics.

2) Look at:

http://aspn.activestate.com/ASPN/Coo.../Recipe/115875

3) Use wmi. Get the wmi module from

http://tgolden.sc.sabren.com/python/wmi.html

and then do something like this:

<code>

import wmi

c = wmi.WMI () # or c = wmi.WMI ("other_computer")
for service in c.Win32_Service (Name="unuseful_service"):
service.ChangeStartMode (StartMode="Automatic")
for service in c.Win32_Service (Name="unwanted_service"):
service.Delete ()

</code>

The loops are just a fudge for the fact the the wmi
query always returns a list, albeit of length one. You
could equally well do:

service = c.Win32_Service (Name="unuseful_service")[0]

although this has the disadvantage (or, possibly, advantage)
of raising an exception if there is no such service.

TJG
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
CollectionEditor - Add/Remove buttons are disabled Dmitry Nogin ASP .Net Building Controls 1 04-28-2007 08:46 AM
Extensions disabled at time change FoxWolfie Galen Firefox 0 10-29-2006 09:55 AM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
Canvas scrolling - scrollBar become "disabled" on change in canvas Askari Python 2 08-30-2004 02:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57