Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Disable Service

Status
Not open for further replies.

Brent113

Programmer
Aug 13, 2003
67
US
How can I disable a running service from visual basic 6. It's not a system service, just something like the iPod service, or the AOL service, for example.

____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't

Brent
 
You can use VB to issue command prompt commands. So, all you need to do is to determine how to stop the services from a command prompt. Once you do that, you can automate it with VB.

For example, if you wanted to stop a SQL Server service, you could do...

Call Shell("cmd /c net stop MSSqlServer")



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Hmm, I forgot you can stop services from cmd, thanks a lot for remembering for me!

____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't

Brent
 
To disable a service, you need to use the following API calls,
OpenSCManager
OpenService
ChangeServiceConfig
CloseServiceHandle


Basically, You need top open a handle to the ServiceControlManager, then use that handle to get a handle to the service you want. You can change the service config according to your needs, then close the handles as required

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
That's what I was looking for, thanks.

____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't

Brent
 
But what about the registry: I googled and found pretty much what I was looking for.

In CurrentControlSet, you can set the start type to DWORD 4 to disable it. I have more experience with the registry, so I'll take that route.

Thanks again to everyone that helped.

____________________________________________________________________________
There are only 10 types of people in the world. Those that know binary and those that don't

Brent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top