Solved

How to create/delete a Windows 2000 service in VB6

Posted on 2003-12-02
5
1,644 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
5 Comments
 
LVL 9

Accepted Solution

by:
Dang123 earned 50 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sorting multiple rows and columns, and count duplicates in Excel 2013 4 79
Help me. 3 55
Message not shown 5 50
Problem to refer to value 8 49
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

777 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