?
Solved

How to create/delete a Windows 2000 service in VB6

Posted on 2003-12-02
5
Medium Priority
?
1,649 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

764 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