Solved

How to create/delete a Windows 2000 service in VB6

Posted on 2003-12-02
5
1,648 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

695 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