Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-29
2
Medium Priority
?
868 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

782 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