473,804 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I'd like to programmaticall y 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.Ch angeServiceConf ig)
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
Jul 18 '05 #1
1 7904
ma************* *@accenture.com (Matt Rapoport) wrote in message news:<41******* *************** ****@posting.go ogle.com>...
I'd like to programmaticall y 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_compute r")
for service in c.Win32_Service (Name="unuseful _service"):
service.ChangeS tartMode (StartMode="Aut omatic")
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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10717
by: DraguVaso | last post by:
Hi, How do you change the Startup Type of a Windows Service with VB.NET? When using the ServiceController you can Start and Stop a Service, but I can't find anywhere how to change the Startup Type? Thanks a lot in advance, Pieter
0
1739
by: normb | last post by:
I'm writing a C# app in which I need to get the Startup type of a couple of services that are registered on the machine. I need to record what the Startup type value is at the time of program execution. However, I'm not having much luck getting this done. Would anyone know how to query a service's Startup type and get the value (either Automatic, Manual, or Disabled) that is set? Thanks!
3
14966
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim swLog As StreamWriter = File.CreateText("C:\myLog.txt") swLog.WriteLine("My Windows Service has just started.") swLog.Close() : swLog.Flush() End Sub
5
1342
by: Adrian | last post by:
Hi is this possible in VB.Net ? How should I go about it? The Idea is the service will run at a given time and shutdown the PC no matter what state it has been left in! Any pointers would be helpful not written much and have never written a service :(
2
3994
by: Varsha | last post by:
Hi, a) I have a windows 2003 server on my machine with in built .NET Framework 1.1. b) I have also installed .NET Framework 1.0 on this machine. c) I have a web service, when i try to invoke the methods of it, it returns "404 not found error".
4
4186
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
2
9739
by: rqcoder | last post by:
Is there a way to change a Service's startup type somewhere in the .net framework? I've been messing around with the System.ServiceProcess namespace which allows me to start, stop and pause services however if the service's startup type is set to "Disabled" there is no way for me to change it to Automatic or Manual... attempting to start a disabled service results in exceptions (i.e. ServiceController.Start).
3
4138
by: Cenarius | last post by:
Hi, I need some help, i don't know much about programming other than executing them get getting them from scripting sites. My program is it won't start a service if the startup type is Disabled. it will try and stop a service that is disabled and will display msg "Error stopping service." if i run script on a service that is already running, it stop then start the service and restarts it again. Thanks whoever has the time to help me. Option...
0
838
by: vsrikanth568 | last post by:
Hi, 1. How to change the service startup type from 'Manual' to 'Auto' or 'Disabled' to 'Auto' using WMI classes in C#? 2. How to change the service startup type using WMI classes in C#? 3. Is there any limitations for changing the service startup type using WMI classes in C#? Thank you, Srikanth.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.