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

Services help

Hello:

We manufacture tools used in the Semiconductor industry that have a DB
engine running on each one. I need to scan through the computers on the
company domain and find which ones have this service installed and it's
current state ( paused, running, stopped, etc ). Can anyone point me to a
set of classes in C# that allow me to find running services on computers
within a Domain?

Thanks for your help

Bob Lazarchik
SDI.
Nov 16 '05 #1
4 2624
Bob

Check out the System.ServiceProcess.ServiceController type.

ServiceController iisService = new ServiceController();

try
{
iisService.MachineName = "MyServer";
iisService.ServiceName = "IISADMIN";

if ( iisService.Status == ServiceControllerStatus.Stopped )
{
Console.WriteLine( "Eek! Get help the websites down" );
}
}
catch ( System.InvalidOperationException )
{
Console.WriteLine( "OOPS! The machine doesn't have the service
installed" );
}

HTH

Glenn

"Bob Lazarchik" <bo*****@sditampa.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Hello:

We manufacture tools used in the Semiconductor industry that have a DB
engine running on each one. I need to scan through the computers on the
company domain and find which ones have this service installed and it's
current state ( paused, running, stopped, etc ). Can anyone point me to a
set of classes in C# that allow me to find running services on computers
within a Domain?

Thanks for your help

Bob Lazarchik
SDI.

Nov 16 '05 #2

Hi Bob:

Here is an article describing a script to enumerate services on remote
machines:
http://www.microsoft.com/technet/com...ts/sg1102.mspx

You should be able to port this to C# using classes in the
System.Management namespace.

HTH,

--
Scott
http://www.OdeToCode.com
On Wed, 25 Aug 2004 06:37:58 -0400, "Bob Lazarchik"
<bo*****@sditampa.com> wrote:
Hello:

We manufacture tools used in the Semiconductor industry that have a DB
engine running on each one. I need to scan through the computers on the
company domain and find which ones have this service installed and it's
current state ( paused, running, stopped, etc ). Can anyone point me to a
set of classes in C# that allow me to find running services on computers
within a Domain?

Thanks for your help

Bob Lazarchik
SDI.


Nov 16 '05 #3
Bob/Scott

Very useful article, here's the C# version....

ConnectionOptions co = new ConnectionOptions();
co.Username = "userName";
co.Password = "password";

ManagementScope scope = new ManagementScope( @"\\myServer\root\cimv2", co );
ObjectQuery query = new ObjectQuery( "select * from win32_service" );
ManagementObjectSearcher mos = new ManagementObjectSearcher( scope, query );
ManagementObjectCollection moc = mos.Get();

foreach ( ManagementObject mo in moc )
{
Console.WriteLine( "{0} : {1}", mo["Name"].ToString(),
mo["State"].ToString() );
}

Check this link out for more info on Win32_Service
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_service.asp

HTH

Glenn

" <bitmask@[nospam].fred.net> wrote in message
news:49********************************@4ax.com...

Hi Bob:

Here is an article describing a script to enumerate services on remote
machines:
http://www.microsoft.com/technet/com...ts/sg1102.mspx

You should be able to port this to C# using classes in the
System.Management namespace.

HTH,

--
Scott
http://www.OdeToCode.com
On Wed, 25 Aug 2004 06:37:58 -0400, "Bob Lazarchik"
<bo*****@sditampa.com> wrote:
Hello:

We manufacture tools used in the Semiconductor industry that have a DB
engine running on each one. I need to scan through the computers on the
company domain and find which ones have this service installed and it's
current state ( paused, running, stopped, etc ). Can anyone point me to aset of classes in C# that allow me to find running services on computers
within a Domain?

Thanks for your help

Bob Lazarchik
SDI.

Nov 16 '05 #4
Very cool, Glenn.

--
Scott

On Wed, 25 Aug 2004 17:19:37 +0100, "Glenn" <cs****@blackwinter.net>
wrote:
Bob/Scott

Very useful article, here's the C# version....

ConnectionOptions co = new ConnectionOptions();
co.Username = "userName";
co.Password = "password";

ManagementScope scope = new ManagementScope( @"\\myServer\root\cimv2", co );
ObjectQuery query = new ObjectQuery( "select * from win32_service" );
ManagementObjectSearcher mos = new ManagementObjectSearcher( scope, query );
ManagementObjectCollection moc = mos.Get();

foreach ( ManagementObject mo in moc )
{
Console.WriteLine( "{0} : {1}", mo["Name"].ToString(),
mo["State"].ToString() );
}

Check this link out for more info on Win32_Service
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_service.asp


--
Scott
http://www.OdeToCode.com
Nov 16 '05 #5

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

Similar topics

0
by: Diego F. | last post by:
I've been days with that. I'm trying to work with web services sending and returning objects, and the web service must store some objects. - My first try (the most obvious in my opinion) was to use...
1
by: christopher green | last post by:
Ok guys I'm tearing my hair out here. As a result of a recent ms patch that has been installed on a server a number of c# based windows services are failing to start. There are no entries in the...
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
21
by: EmJayEm | last post by:
Can someone tell me the Disadvantages/Cons of web services? Thanks, EmJ.
7
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
1
by: rmk | last post by:
How can I get the 2000 and 2005 versions of SQL Server Reporting Services both working on my development laptop ????? I have ASP.NET 1.1 and 2.0 installed on my laptop. I have Visual Studio...
2
by: sdstraub | last post by:
I have created 5 services in my project, in the 1st service I set servicestorun = array of all 5 services, I have a project installer with 5 service installers, one for each service. I have code...
0
by: krishnaraju | last post by:
HI to all, please help me.its urgent requirement. my question is this is the wsdl file i got from our client.please see at bottom. when iam trying to access that webmethods iam getting...
5
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
This code works fine in Windows Application. In Windows Application, I am able to zip the image files properly and it totally contains 900MB My problem is the same code which I used in my Windows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.