Solved

Starting/Stopping a service on another machine remotely from VB.NET

Posted on 2006-06-29
2
859 Views
Last Modified: 2012-05-05
Can I start and stop services to another machine via VB or VB.NET code?  I have seen some code that allows me to start and stop a service on the same machine.  I did not see any parameter for machine name. If possible any sample code would be appreciated...Thanks

0
Comment
Question by:andyringle
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 17017662
It's actually pretty straight forward...

' add a reference to System.ServiceProcess.dll
Imports System.ServiceProcess

        Dim sc As ServiceController
        sc = New ServiceController("TermService", PC)
        sc.Start()
        sc.WaitForStatus(ServiceControllerStatus.Running)

and

        sc = New ServiceController("TermService", PC)
        sc.Stop()
        sc.WaitForStatus(ServiceControllerStatus.Stopped)
0
 

Author Comment

by:andyringle
ID: 17018378
Thanks, that worked perfectly!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now