473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Disabling a service

Hi all.

I am using the ServiceController class to interface with a service on a
Windows 2003 Server. However, I cannot work out how to disable the
service or set it to manual. Starting it and stopping it works fine
but of course, after rebooting, the service restarts because it is set
to Auto.

Any ideas on how to do this? I would rather not use WMI unless there
is not alternative simply because I can do everything else without it!

Thanks.

Nov 23 '05 #1
4 1142
In the projectInstaller.vb, in the properties of the serviceinstaller,
set the startup to manual instead of automatic...

To disable the service i think you must uninstall it... you can run a
..bat file with a call to the installutil.exe /u

Good Luck :)

Nov 23 '05 #2
Sorry, I guess I did not make myself clear. The app I am writing is
*not* a windows service, but a normal app. It interfaces with various
windows services that I need to manipulate. I need to disable one of
these windows services as it is no longer required but i do not want to
uninstall it.

Nov 23 '05 #3
Hugh,
Unfortunately (or is it fortunately) you cannot. As ServiceController is
really intended to manipulate the current instance of an *existing* service,
not the configuration of a service.

I know ServiceInstaller can, as it is intended to configure a service when
you install it. ServiceInstaller may be over kill in this case. My concern
with ServiceInstaller is changing more config then one should.

I'm not sure if WMI can change the configuration of a service.

I suspect you will need to call the Win32 API, unfortunately I don't have
examples of calling said Win32 API... If I find a sample or the API itself

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Hugh Janus" <my*************@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
| Hi all.
|
| I am using the ServiceController class to interface with a service on a
| Windows 2003 Server. However, I cannot work out how to disable the
| service or set it to manual. Starting it and stopping it works fine
| but of course, after rebooting, the service restarts because it is set
| to Auto.
|
| Any ideas on how to do this? I would rather not use WMI unless there
| is not alternative simply because I can do everything else without it!
|
| Thanks.
|
Nov 23 '05 #4
The Win32 API you're looking for is ChangeServiceConfig
You can pass null (IntPtr.Zero) for most parameters

/claes

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hugh,
Unfortunately (or is it fortunately) you cannot. As ServiceController is
really intended to manipulate the current instance of an *existing* service, not the configuration of a service.

I know ServiceInstaller can, as it is intended to configure a service when
you install it. ServiceInstaller may be over kill in this case. My concern
with ServiceInstaller is changing more config then one should.

I'm not sure if WMI can change the configuration of a service.

I suspect you will need to call the Win32 API, unfortunately I don't have
examples of calling said Win32 API... If I find a sample or the API itself

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Hugh Janus" <my*************@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
| Hi all.
|
| I am using the ServiceController class to interface with a service on a
| Windows 2003 Server. However, I cannot work out how to disable the
| service or set it to manual. Starting it and stopping it works fine
| but of course, after rebooting, the service restarts because it is set
| to Auto.
|
| Any ideas on how to do this? I would rather not use WMI unless there
| is not alternative simply because I can do everything else without it!
|
| Thanks.
|

Nov 23 '05 #5

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

Similar topics

20
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to...
0
by: Paul Smith | last post by:
I have been given an unusual task to create a Windows Service to do something periodically to make the screensaver timer reset. We have a general policy of locking computers automatically after 10...
0
by: ChrisC | last post by:
Im having some trouble disabling hardware using WMI. I got a handle on the device, but when I call SetPowerState I get a type mismatch. The definition of the method says it takes an int (power...
3
by: TR | last post by:
Hi, We have some code that uses automation to create/manipulate word documents. This runs in a batch mode, generating dozens of documents in sequence. The code works great, but while the...
3
by: PB | last post by:
What is the rationalle for disabling JavaScript. AFAIK, the primary reason is for "security purposes" - but what specific kind of threats does the protect against? AND - is the disabling of...
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
7
by: =?Utf-8?B?SmVmZkRvdE5ldA==?= | last post by:
I have an asp.net application using a multi-page wizard control that grabs user selected files from a database and allows the user to configure parameters using controls on the wizard pages. The...
7
by: SAL | last post by:
Hopefully someone will have a clue as to what is happening here. In our office, we have both ColdFusion and ASP.NET applications. One of our new developers has been installing ColdFusion 8 on the...
5
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.