Solved

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

Posted on 2006-06-29
2
865 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of convertingā€¦
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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