Hi
I had a look at this topic on the net and came accross some code. I havent tried it but maybe give this a shot:
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" ,"")
To Remove the 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
Regards
Marnus
|