473,385 Members | 1,782 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.

get the status of a windows server service using vb.net

5
THis is my vb.net code

Expand|Select|Wrap|Line Numbers
  1.     Public Class TS_Service
  2.  
  3.         ' Is the service running?
  4.         ' Returns true if we need to start the service
  5.         Public Function CheckService(ByVal PC As String) As Boolean
  6.             Dim obj As ManagementObject
  7.             obj = New ManagementObject("\\" & PC & "\root\cimv2:Win32_Service.Name='SBAMSvc'")
  8.             '     If Not IsNothing(obj) Then
  9.             If obj("State").ToString = "Running" Then
  10.                 Return False
  11.                 'End If
  12.             End If
  13.             Return True
  14.         End Function




I am receiving an error,
Class 'myprojectname.managementobject' cannot be indexed because it has no default property
Jan 2 '13 #1
7 2621
PsychoCoder
465 Expert Mod 256MB
Try changing your Dim statement to look like this:

Expand|Select|Wrap|Line Numbers
  1. Dim obj As New ManagementObject("\\" & PC & "\root\cimv2:Win32_Service.Name='SBAMSvc'")
Jan 2 '13 #2
rjszum
5
Unfortunatly, this did not fix issue. same error
Jan 2 '13 #3
rjszum
5
I simplified my code but still same error.

Expand|Select|Wrap|Line Numbers
  1. Private Sub listservices3()
  2.         '  Dim obj As ManagementObject
  3.  
  4.         Dim obj As New ManagementObject("\\server01\root\cimv2:Win32_Service.Name='tomcat6SPI'")
  5.       obj("State").ToString = "Running" Then
  6.         If obj("State").ToString = "Running" Then
  7.             Me.Label2.ForeColor = Color.AliceBlue
  8.         End If
  9.  
  10.     End Sub
Jan 2 '13 #4
Rabbit
12,516 Expert Mod 8TB
You need to declare a default property in the ManagementObject class. If you cannot, as I suspect it is a class where you don't have access to the source, then you must specify which property you are setting.
Jan 3 '13 #5
rjszum
5
I am unsure how to do this, but it seems like this is probably the issue. I am trying to get the Status of the service. the state which would be "Running", "Stopping" or blank(meaning Stopped)
Jan 3 '13 #6
PsychoCoder
465 Expert Mod 256MB
I guess you could contact the original writer of that code here and ask if they got the same error and if so how they resolved it.
Jan 3 '13 #7
Rabbit
12,516 Expert Mod 8TB
Well, since you changed the way you are instantiating your object, the issue may be that you didn't escape your forward slashes.
Jan 3 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: MikeRoft | last post by:
Hi, We have a big application in .Net using the No-Touch deployment. Everything is working perfectly. Now we manage to install it on Windows Server 2003 using IIS. We have some problem...
1
by: sureshbabu | last post by:
Hello everybody Can any one tell me how to develop windows nt/2000 service component which does some monitoring (any work. I would like to use vc++ 6.0 and AT Thanks in advance
0
by: Doug | last post by:
If you've found that controls such as any type of button are suddenly no longer causing a postback, when they should: It's related to the webuivalidation.js which has just been updated in a...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
2
by: Jeffrey Tate via DotNetMonster.com | last post by:
The error is: The proxy settings on this computer are not configured correctly for Web discovery. MSDN states that this is caused by: This error appears in the Add Web Reference dialog box if...
1
by: Simon Verona | last post by:
Hope somebody can help. I have a web service written in vb.net which works fine localling on my Windows XP Pro development machine without a problem. I have deployed in onto a Windows Server...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
0
by: BuddyWork | last post by:
Hello, I'm doing a stress test and my test graudually increases the connections to the webservice. Everything works well until my connection hits around 350 connections. The new connections...
0
by: JDF | last post by:
I am trying to create a Windows service using SimpleXMLRPCServer and win32serviceutil. The service itself seems to be working properly (starts, stops, etc) and I can connect using an XMLRPC client...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.