Link to home
Start Free TrialLog in
Avatar of GeekMan
GeekMan

asked on

Starting Services in VB

I am looking for sample code that shows how to start Windows Services from VB by using the Win32 API or other means.
Thanks...
Avatar of aelatik
aelatik
Flag of Netherlands image

Avatar of RanaHossain
RanaHossain

talk about a coincidence - I spent the whole day yesterday trying to get my application as a service.

first tried using servany.exe - which you can download from the net - it also comes with 2 other files that allows you to run a service...

now that did create the service, but was not running.

so found some api.. and same deal.

finally I figured it out - services needs to be event driven - so downloaded a copy of NTSVC.OCX, and with events you can install, start, stop, pause, uninstall the service.

If you want to avoid the agro and grief of using pointers in structures, copymemory etc etc to Win32 API, then try Windows Management Instrumentation, much easier and less grief here are some useful links for you to check out:


WMI Win32_Service
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_service.asp

And some easy code examples on info above:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_ser_bwdq.asp


I wrote my own Service Control Program using just WMI, it does pretty much what the Win32 APIs do, except for a few things. But I am sure you'll find the WMI Win32_Service class does all what you need.
ASKER CERTIFIED SOLUTION
Avatar of Glen A.
Glen A.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial