Solved

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

Posted on 2006-06-29
2
866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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