473,397 Members | 1,974 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,397 software developers and data experts.

Changing the startup type on a remote system

I am trying to write a little utility and it needs to check the startup type
of a given service on a remote machine and, if it is disabled, set it to
manual. I have found out how to do this on the local machine using
ServiceInstaller.StartType, but I cannot seem to find a way to specify the
name of a remote machine to perform this action upon.

I know that ServiceController will allow me to talk to a remote system and
start/stop services, but it lacks the methods and properties I need for
StartupType.

I'm pretty new to .NET, so It's quite likely I'm simply looking in the wrong
place, but a day of Googling has left me without an answer. If someone could
point me in the correct direction to solve this, I would be most grateful.
If this is the wrong group, that would also be helpful info.

If anyone has suggestions on good reference manuals with a strong lean
towards system and networking programming, I'd like to hear about them.

TIA,

ne.
Apr 6 '07 #1
6 4811
Hi,

You may find following example code useful for your purpose:

#Extend ServiceController class to change the StartupType of Windows
Services - The Code Project - System Programming
http://www.codeproject.com/cs/system...controller.asp

Please let me know if this works for you. Thanks.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 9 '07 #2

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:jR**************@TK2MSFTNGHUB02.phx.gbl...
Hi,

You may find following example code useful for your purpose:

#Extend ServiceController class to change the StartupType of Windows
Services - The Code Project - System Programming
http://www.codeproject.com/cs/system...controller.asp
This does do what I'm looking for, but it still seems to leave me with the
problem of specifying the target system. This example seems to be operating
on the local system & I haven't been able to spot a property to specify a
remote system name. Maybe I'm missing it?
Apr 9 '07 #3

"NetworkElf" <ne********@nospam.nospamwrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
>
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:jR**************@TK2MSFTNGHUB02.phx.gbl...
>Hi,

You may find following example code useful for your purpose:

#Extend ServiceController class to change the StartupType of Windows
Services - The Code Project - System Programming
http://www.codeproject.com/cs/system...controller.asp

This does do what I'm looking for, but it still seems to leave me with the
problem of specifying the target system. This example seems to be
operating on the local system & I haven't been able to spot a property to
specify a remote system name. Maybe I'm missing it?
OK, I'm thinking something like this:

dim myObject as Management.Object

myObject.CreateObjRef()
However, I'm uncertain where to go from there. Could anyone point me to an
example showing how this is used to connect to a remote system?

Thank you.
Apr 9 '07 #4
Hi,

Sorry about the confusion, yes the example code is not completely correct
since it always used a local WMI object path to query the service. We need
to modify it using following code:

1) Add a private property WmiPath:

private string WmiPath
{
get {
return "\\\\" + this.MachineName + "\\root\\cimv2:Win32_Service.Name='"
+ this.ServiceName + "'";
}
}
2) Modify the properties Description, StartupType to use this WmiPath
property to pass to the ManagementPath constructor.
By the way, the code is changing the service startup type using WMI, you
can find more information here:

#Win32_Service
http://msdn2.microsoft.com/en-us/library/aa394418.aspx
Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 10 '07 #5

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:aj**************@TK2MSFTNGHUB02.phx.gbl...

Thank you, Walter. I'll see what I can do with this after I've had time to
read the link you included.

I'm curious though, is there a reason for not including the startup type
property in ServiceController? I'm sure there's a reason, but, being new to
..NET, it eludes me.

Thank you for your help.
Apr 10 '07 #6
Hi,

The startup type isn't usually changed during execution of an application
that uses the service, it is not part of the ServiceController. On ther
other hand, WMI is designed to do such job and .NET has support of WMI
(such as the above code is using ManagementPath to change the Win32_Service
object).
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 11 '07 #7

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

Similar topics

3
by: Bernd Giegerich | last post by:
Hi, we had a strange problem with DB2 8.2 Enterprise Edition on Windows 2003 (Standard) Server. We installed DB2 8.2 (8.1.7) directly on a naked W2K3 system (no migration, no update -> no...
27
by: Alex Levi | last post by:
When I'm changing a forms name in the project and this form is a startup form (set in the project properties), I get an error that the function "sub main" is not found. The visual basic should...
4
by: Larry | last post by:
I have a Perl script using DBD::DB2, that runs during system startup on a Solaris system. The script is working fine during startup on many machines, except on one machine it fails complaining...
10
by: Bernie Hunt | last post by:
This is probably a silly question, but I've gotten myself confused. My app has two forms, form1 and form2. form1 is the start up object in the propers. An event in form1 instantiates form2. ...
3
by: steveeisen | last post by:
I'm a long-time VB6 programmer in a shop that is mostly moving to VB ..NET 2005. And I'm confused about coding the start of solutions for unattended operations. Much of what I write is old-time...
2
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...
4
by: vncntj | last post by:
I've tested this project locally, by running it http://localhost:1436/Data/gift.aspx and everything is perfect. But if it onto the remote server I get "The type or namespace name could not be...
13
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one...
7
by: Larry Neylon | last post by:
Hi there, We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config. We currently have a system that on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...
0
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...

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.