?
Solved

How to create/delete a Windows 2000 service in VB6

Posted on 2003-12-02
5
Medium Priority
?
1,652 Views
Last Modified: 2013-11-13
Hi

How can i create and delete a Windows 2000 service in VB6?
I also want to know if a particular service is running. How can I detect that through VB6?

Thanks
Siva
0
Comment
Question by:siva_manikoth
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Dang123 earned 200 total points
ID: 9857950
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 9862980
For Installing a service: - This example is installing a service called "Personal Database" with the path to the .exe

Const OWN_PROCESS = 16
Const NOT_INTERACTIVE = True
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objService = objWMIService.Get("Win32_BaseService")
errReturn = objService.Create ("DbService", "Personnel Database", _
  "c:\windows\system32\db.exe", OWN_PROCESS ,2 ,"Automatic" , _
      NOT_INTERACTIVE ,".\LocalSystem" ,"")

For Removing a service:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Service WHERE Name = 'DbService'")
For Each objService in colListOfServices
    objService.StopService()
    objService.Delete()
Next



0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10211908
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered Dang123
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

leonstryker
EE Cleanup Volunteer
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 10215230
lol, whatever
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question